UITableViewCell reorganize subviews when the 'delete' button appears

牧云@^-^@ 提交于 2019-12-06 13:35:43

问题


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

There could be two methods:

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


回答1:


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
}

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



来源:https://stackoverflow.com/questions/1928631/uitableviewcell-reorganize-subviews-when-the-delete-button-appears

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!