Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView Section Header issue
    text
    copied!<p>All,</p> <p>I have a grouped UITableView with a possible total of 3 sections. There could be 1, 2 or 3.</p> <p>My issue is that for each section I use a different header &amp; footer view. I am choosing which header/footer to show by checking the section #.</p> <p>This obviously does not work, as section 0 does not always represent what 'header' 0 shows.</p> <p>Example: Header #0 = "Game in progress". But no games in progress are returned from the database. Only 'Games Ended" exist. Therefore section 0 would be all 'games ended'. I don't want 'Games Ended' to use the 'Games in Progress' header.</p> <p>I can't find a way to check the section value, and not the number.</p> <p>To put it simply, I would like to be able to show section header #3 for section name #3, even if section name #3 is section #0.</p> <p>I know this seems trivial, and is probably simple... but I am stuck. Any help is appreciated.</p> <p>Thanks.</p> <p>----- CODE -----</p> <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [[fetchedResultsController_ sections] count]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { id &lt;NSFetchedResultsSectionInfo&gt; sectionInfo = [[fetchedResultsController_ sections] objectAtIndex:section]; return [sectionInfo numberOfObjects]; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { if(section == 0) { return 50.0f; } else if (section == 1) return 50.0f; else return 50.0f; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { if(section == 0 ) { return 50.0f; } else if (section == 1) return 5.0f; else return 80.0f; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { if(section == 0) { return headerView1; } else if (section == 1) return headerView2; else return headerView3; } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { if(section == 0) { return footerView1; } else if (section == 1) return footerView2; else return footerView3; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload