How can I change the amount of indentation on my custom UITableViewCell while editing?

前端 未结 2 392
没有蜡笔的小新
没有蜡笔的小新 2020-12-14 13:48

I have made a custom UITableViewCell, and done it properly (adding everything to contentView, and overriding layoutSubviews so my subviews are rela

2条回答
  •  余生分开走
    2020-12-14 14:09

    Nick Weaver's updated answer works great, except for the issue that Rec Levy pointed out:

    Only thing now is that when you swipe-to-delete and then cancel (click elsewhere on the screen) the cell suddenly skips to the left and then slides back as the delete button disappears

    I ran into the same problem. I'm not sure why it's occurring, but disabling animations while setting the contentView frame resolves it.

    ...
    [UIView setAnimationsEnabled:NO];
    self.contentView.frame = CGRectMake(indentPoints,
                                            self.contentView.frame.origin.y,
                                            self.contentView.frame.size.width - indentPoints, 
                                            self.contentView.frame.size.height);
    [UIView setAnimationsEnabled:YES];
    

提交回复
热议问题