如何在自定义UITableViewCell中控制UITextField的编辑

时间:2012-03-01 12:17:35

标签: iphone objective-c ios uitableview uitextfield

我有一个UITableViewCell的自定义(子类),里面有多个UITextField。

我想这样做,以便当TableView处于编辑模式时,单击UITextField将启用TextField的编辑。但是,当不处于编辑模式时,单击单元格(或其中的任何UITextField)选择单元格,以便通过didSelectCellAtIndexPath方法控制行为。

最好的方法是什么?

非常感谢提前

1 个答案:

答案 0 :(得分:3)

最好的方法(也是最优雅的)是覆盖单元格的setEditing:(BOOL)editing animated:(BOOL)animated方法:

- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
    [super setEditing:editing animated:animated];
    self.textField.enabled = editing;
}

如果您需要继承公共UITableViewCell

的行为,请记得调用super
相关问题