There are some section in the table that does not contain any data and would like to hide that section.
How to do this?
You can also return the number of records that do contain data from the
numberofSectionsInTableView:
method and use a
switch(indexPath.section)
where you let the empty records 'fall through' to the next switch, like:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.section) {
case 0:
return ;
break;
case 1:
if(firstRecordHasData){
return ;
break;
}
case 2:
if(secondRecordHasData){
return ;
break;
}
case 3:
return ;
break;
default:
return ;
break;
}
}
I was struggling with this for a while because I had to leave out sections in the middle of a grouped table. Tried with setting cell-, header- and footer heights to 0.0 but that didn't work. Couldn't just delete certain sections because of the called methods depending on the selected row. This was going to be a huge if..else if...else if with multiple callings of subroutines. Glad I thought of the good old switch method, maybe it helps you as well :-)