当出现"删除"按钮时,UITableViewCell会重新组织子视图

mxg*_*mxg 1 iphone objective-c uitableview uilabel

Delete按钮出现时,有没有人知道任何调整子视图大小的方法(IE UILabelView).

可能有两种方法:

1.当按钮出现在UITableViewCell中时,捕获通知(如果有的话).2.框架自动重新排列它.

mjd*_*dth 7

在UITableViewCell类的.m文件中使用layoutSubviews.每次调整单元格大小时都会调用它,删除按钮会出现/消失,以及更多:

- (void) layoutSubviews {

    [super layoutSubviews];


    frame = self.contentView.bounds; ///this is the availalbe space for the cell
    ///it's automatically adjusted when the delte button appears
    ///so use it to resize all of your interface elements
}
Run Code Online (Sandbox Code Playgroud)

您还可以if (self.editing) {在layoutSubviews内部使用以获得更多控制.