我试过了this在自定义单元格中插入 uitextfield 的 url,但我不确定何时保存修改后的内容。
请告诉我并表示感谢。
最佳答案
一种方法是让您的 UITableViewController 实现 UITextFieldDelegate 协议(protocol),然后将其指定为嵌入 CustomCell UITableViewCellSubclass 中的 UITextField 的委托(delegate)。
您首先需要在 TableView Controller 子类中实现 UITextFieldDelegate 协议(protocol)...
MyTableViewController : UITableViewController <UITextFieldDelegate>
然后在您的子类中添加 textFieldShouldReturn:(UITextField*)textField 方法的实现。当用户完成编辑单元格 UITextField 的内容时,将调用此方法...
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
NSString *enteredText = [textField text];
// .. do something with the text
}
最后,您需要将 CustomCell 的 UITextField 的委托(delegate)属性设置为 UITableViewController 子类。为此,只需向现有的 tableView:cellForRowAtIndexPath: 方法添加一个方法调用...
cell.textField.delegate = self;
关于iphone - 如何保存自定义单元格内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10649301/