问题描述
我想在编辑模式下更改 UITableviewCell
的外观,就像苹果通讯录中显示的那样。单元格应该调整大小,我将添加 UITextFields
作为子视图。
我知道要更改单元格的外观,您必须覆盖单元格中的 LayoutSubviews
函数。我尝试这样做,并且产生了一些有趣的效果并调整了大小:-)
I want to change the appearance of an UITableviewCell
in edit mode like it is shown in the address book from apple. The cell should resize and i will add UITextFields
as subviews.I know that to change appearance of a cell you have to overwrite the LayoutSubviews
function in the cell. I tried to do that and i had some funny effects and resizing :-)
我已经寻找了一段时间,在网上找到了一些提示,但是我没有找到。
如果有人可以提供一些提示,说明如何正确执行此操作?
I have looked for a while to find some hints on the net but i didnt find one.If anyone could provide some hints how to do this right? Links to tutorials or code will be fine.
感谢
涡流
推荐答案
覆盖 setEditing:animated:
并在其中重新加载表格视图单元格不是一个好主意。
这非常耗费资源,而不是正确的位置。
It's NOT a good idea to overwrite setEditing:animated:
and reload your table view cells there.That is very resource-expensive, and not the right place to do it.
在 UITableViewCell $ c的子类中$ c>,重写方法didtransitionToState:
在那里,您可以直接对单元出口进行操作,例如:
In the subclass of UITableViewCell
, override method didtransitionToState:There, you can act directly on the cell outlets, like so :
- (void)didTransitionToState:(UITableViewCellStateMask)state
{
[super didTransitionToState:state];
if (state == UITableViewCellStateShowingEditControlMask) {
// edit mode : peform operations on the cell outlets here
} else if (state ==UITableViewCellStateDefaultMask) {
// normal mode : back to normal
}
这篇关于UITableViewCells在编辑模式下更改大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!