I have a UITableView
with 4 sections. Three of these sections have a header view.
The header view is a UITableViewCell
, which I am de-queueing as a normal cell in the viewForHeaderInSection:
delegate.
If I insert or delete a row from any section, the other tableview
header cells disappear.
I'm assuming this has something to do with cell reuse, however the cells initially all appear on screen (all three headers appear onscreen at the same time).
I've tried reloading the other sections after the insert or delete, but that doesn't help.
Here's some code:
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
switch (section) {
case kSectionCardInformation:
case kSectionContactInformation:
case kSectionTags: {
static NSString *CellIdentifier = @"EditContactHeaderCell";
EditContactHeaderCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
return cell;
}
default:
return nil;
}
}
And here is where I delete the row in the revelant section:
- (void)deleteTag:(CDTag *)tag {
[self.tableView beginUpdates];
NSMutableArray *objects = [self.sections objectAtIndex:kSectionTags];
if ([objects containsObject:tag]) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[objects indexOfObject:tag] inSection:kSectionTags];
[objects removeObject:tag];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationMiddle];
[self.contact deleteTag:tag];
}
[self.tableView endUpdates];
}
Any help, greatly appreciated.