Reputation: 1191
I have to make a tableview with different cells in it. I have three preferences and the table depends on them. There may be 6 different tableviews - 1 cell, 1cell and 3cell, no cell, 2 cell and 3 cell and so on, this depends on preferences
That's the best way to do this?
Maybe someone knows good example, or tutorial on this
Upvotes: 0
Views: 188
Reputation: 1326
You could make just one UITableView
with different sections.
Based on your section id you may be returning different cell in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
indexPath
contains row
& section
values.
Also you might return different number of rows in a section with:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
Upvotes: 1
Reputation: 4901
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//pass value to numper of cells;
return 4 (or) 2;
}
//use this to add cell
[tableview reloadData];
Upvotes: 1