I have a table with custom header views that no matter when, or what value I choose for section, I always get nil value. I have another table with the same problem.
It's been awhile since this question was asked and recently I had come across a similar issue and had asked my own question here: UITableView -headerViewForSection returns (null)
I believe I have the answer.
UITableViewHeaderFooterView subclass and name it CustomHeaderViewiPadTableCells here)CustomHeaderView@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;Use the following code:
- (UIView*) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
static NSString *HeaderIdentifier = @"header";
CustomHeaderView *header = [tableView dequeueReusableHeaderFooterViewWithIdentifier:HeaderIdentifier];
if(!header) {
NSArray* objs = [[NSBundle mainBundle] loadNibNamed:@"iPadTableCells"
owner:nil
options:nil];
header = [objs objectAtIndex: 0];
}
[header.activityIndicator startAnimating];
return header;
}
then you can access it this way:
CustomHeaderView *headerView = (CustomHeaderView*)[tableView headerViewForSection:section];
[headerView.activityIndicator stopAnimating];