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

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

问题描述

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

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

可能有两种方法:

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

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
}

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

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

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

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