0

I am new to stack overflow. I am developing a mobile app for iOS. In which I want to display all my records from the database in my single view controller. I can assign label for each data in the record. But it is not possible to assign label for each data in the database. So kindly advice me to display the records as a set. Like.

  1. 1st Record - Data, data, data, etc.,

  2. 2nd Record - Data, data, data, etc.,

I need this in a scroll view. Like eCommerce products listing page.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Rokesh
  • 37
  • 1
  • 9

2 Answers2

0

If you want to display your data, yet have distinct groups, you could use a UITableView and set its style to grouped. This way, you can present the data in a scrollable fashion, yet have the data grouped together. An example of this is the Settings App homepage. The data (each section) is scrollable, yet there are dividers between them. They are displayed together, yet grouped.

Another benefit of a grouped UITableView is the fact that each section can have a title / label. Basic setup is as follows.

UITableView * tableView = [[UITableView alloc] initWithFrame:... style:UITableViewStyleGrouped];

You can manage everything to do with the data with the two protocols, UITableViewDelegate, UITableViewDataSource. Managing section labels is easy with the following delegate method.

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
Brian Tracy
  • 6,801
  • 2
  • 33
  • 48
0

It Depends on your requirement as if you like to show them in a list then you can go for UITableView and if like to display them in a grid then you can use UICollectionView

  1. UITableView --- To Display content in a sequential list
  2. UICollectionView --- For Grid of n*m rows and column