iOS increase edit mode indentation for custom UITableViewCell
I've got a UITableView
with the ability to delete the rows using edit mode etc. As standard, when you tap the 'edit' button, you go into edit mode and the content of the cells gets moved to the right. If you do a 'swipe to delete', the cell content stays where it is.
What I want to do is increase the indentation when you enter edit mode. I've tried the UITableView
delegate method indentationLevelForRowAtIndexPath
but that doesn't seem to work when I'm using a UITableViewCell
subclass.
In the end I used the layoutSubviews method in my UITableViewCell subclass. Below is my code:
- (void)layoutSubviews
{
[super layoutSubviews];
CGRect b = [self bounds];
if(self.editing && !self.showingDeleteConfirmation){
b.origin.x = 42;
}
[self.contentView setFrame:b];
}
T开发者_Go百科his indents the cell content further when you enter edit mode and thanks to the "!self.showingDeleteConfirmation
", when you do a 'swipe to delete', it doesn't indent it.
However, when you tap the 'edit' button, then tap one of the circle delete buttons, the cell content slides back to the original 0 x axis position. This is because the showingDeleteConfirmation
is now set to true.
I've tried to fix this by checking what the current origin.x
value is, but every time I check, it's set to 0.
Is there a way I can achieve what I want?
精彩评论