UITableView delete editing pushes cell content to the right
When setting [self.tableView setEditing:TRUE];
开发者_如何学编程on a tableView the native table delete editing icons appear to the left. But when using a plain styled table these round icons pushes my row background (and content) to the right.
How can I prevent the editing style from changing my cell position, and instead put the icon on top off the cell?
The way it is now it looks like a bug.
Another question on this. Is there some way to define indexPath.row == 0
to not have an delete icon on setEditing:TRUE
?
- Set cell's
shouldIndentWhileEditing
property toNO
. Implement delegate's
tableView:editingStyleForRowAtIndexPath:
method and return appropriate value from it, e.g.:- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.row == 0) return UITableViewCellEditingStyleNone; return UITableViewCellEditingStyleDelete; }
Ok, found why #1 was not working. I hade set my row background as a view on cell.contentView, in stead of putting it on cell.backgroundView. This way the built in functionality could not separate background from content.
The shouldIndentWhileEditingRowAtIndexPath function will only prevent background from indenting, and not content, as there has to be room for the editing icon.
精彩评论