Reputation: 600
I have a UITableView with three Cell Prototypes in the storyboard, I use one cell in the header section, one for the normal table rows and another for the table footer.
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
static NSString *CellIdentifier = @"Header";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//some personalization
return cell;
}
My problem is whenever i enter in the edit mode of the tableview the header and footer are moving to the left, like the cell that is current editing.
- (void) setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
[self.tableView setEditing:editing animated:animated];
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
return YES;
}
In edit mode:
Any solution or hints? Neither the last XCode update fixed it.
Thank you
Upvotes: 0
Views: 2415
Reputation: 41
Along the way I found out that it's perfectly fine using a tableViewCell
, you just return the cell contentView
and the indention for the header while editing is gone.
Upvotes: 4
Reputation: 61
I solved the issue of "moving" headers with creating a header with a UIView instead of UITableViewCell. You can do it by simply dragging a UIView out to the UITableView it will place it right above/between prototype cells. Then you can treat it as and view in Interface Builder. You can create a controller for it, but imho it is quicker and easier to give it a tag
and then use tableView.viewWithTag(tag)
. Hope it helps!
Upvotes: 0
Reputation: 600
Solved. Basically I had to create a UIView and use that in as My header / footer, and not use a UITableViewCell.
Thanks to
Table Header Views in StoryBoards and
Stick UITableView header view to top when creating header in storyboard
Upvotes: 4