Reputation: 3052
Ok, so there is "static cells" content mode for creating settings-like views. Can anyone suggest how to deal with that if you have different number of settings to be displayed in different circumstances? i.e. in one case I have three cells: two cells with switches and one with button, and in other case - just last cell with button.
Should I switch back to dynamic cells? How should I handle headers' behavior in this case? Thanks
Upvotes: 1
Views: 408
Reputation: 376
I think you better use dynamic cells. for header and footer of cells and sections you can just call this methods:
- (NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return @"This will be the header!!!!";
}
or
- (NSString *) tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
return @"This will be the footer!!!!";
}
P.S. there were some methods, something like "viewForHeaderInSection"
and "viewForFooterInSecton"
. But I don't remembre the complete implementation.
P.S^2. you have to set the Table View Style to Grouped! See this image for a tiny help
Upvotes: 1
Reputation: 32681
Static cells and a simple if
in your implementation of numberOfRowsInSection:
and cellForRowAtIndexPath
to return your 3 static cells or just the last one depending on your condition. Simple enough.
Upvotes: 0