I have a custom view with a UILabel
and UIButton
that I use for my grouped UITableView
section headers like so:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
sectionHeaderView *headerView = [[sectionHeaderView alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
[headerView.label setText:[[self tableView:tableView titleForHeaderInSection:section] uppercaseString]];
if (_tableView.editing)
[headerView.button setHidden:NO];
return headerView;
}
As you can see, I want to unhide the button when the UITableView
is in editing mode.
I use a UITableView
category method to return visibleHeaders so that I can refresh visible section header views without calling reloadData or reloadSections:withRowAnimation. That method basically returns an array of NSNumber objects and it works great.
Here is the method that sets UITableView
in editing mode:
- (void)tapThatEditButtonBaby
{
[_tableView setEditing:YES animated:YES];
for (NSNumber *sectionNumber in _tableView.visibleHeaders) {
NSInteger section = [sectionNumber integerValue];
sectionHeaderView *headerView = (sectionHeaderView *)[self tableView:_tableView viewForHeaderInSection:section];
[headerView setBackgroundColor:[UIColor redColor]]; // highlighting view for testing.
}
}
What would be a nice way of solving this one? Ideally, in my opinion, I'd like to be able to call something like updateSectionAndFooterAtIndex: from UITableView
, but there isn't such exposed method... :(