当“删除”按钮出现时,UITableViewCell重新组织子视图 [英] UITableViewCell reorganize subviews when the 'delete' button appears

查看:108
本文介绍了当“删除”按钮出现时,UITableViewCell重新组织子视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Does anyone knows any method to resize subviews(I.E. UILabelView) when Delete button appears.

有可能有两种方法:

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

1.Capture a notification, if there's one, when the button appears in the UITableViewCell 2.Tell the framework re-arange it automatically.

推荐答案

在UITableViewCell类的.m文件中使用layoutSubviews。每次调整单元格大小时都会调用它,删除按钮会显示/消失,等等:

In your UITableViewCell class's .m file use layoutSubviews. It is called every time the cell is resized, the delete button appears/disappears, and more:

- (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
}

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

You can also use if (self.editing) { inside of layoutSubviews for more control.

这篇关于当“删除”按钮出现时,UITableViewCell重新组织子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆