tags:

views:

468

answers:

2

The tableview, custom table header, and custom section headers are loaded from a NIB. The tableview is grouped.

When the view loads, the first section header doesn't show up. If I scroll down, the other section headers will appear at first, but will disappear as soon as the section above them touches the top of the screen.

If I scroll back up so that a disappeared section header is off the screen, then scroll back down, it will usually reappear.

The problem is fairly consistent but not entirely- sometimes I have to scroll up and down several times to get a header to reappear. Any ideas as to what could cause this?

A: 

Your custom views must be (or descend from) UILable or UIImageView objects. You may need to manually set row height for the headers to get custom views to load and display properly.

You should review the details in the UITableViewDelegate protocol.

Specifically, look at these methods:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

and

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

Part of the discussion on the tableView:viewForHeaderInSection: method states:

This method only works correctly when tableView:heightForHeaderInSection: is also implemented.

Chip Coons
"The returned object, for example, can be a UILabel or UIImageView object." It doesn't sound like it's required to be one of those types, they were just giving an example. The method specifies a UIView* is returned. I tried returning a simple UILabel and it didn't make a difference anyway. I have implemented heightForHeaderInSection. Thanks for the comment, but any other ideas?
Rob Lourens
A: 

I fixed it- I was using one UIView for 3 sections, changing the text appropriately then returning it. Creating separate UIViews in the NIB for each section fixed the problem. So I guess you can't do that.

Rob Lourens