开发者

How do I save text from a UITextField in a UITableViewCell?

开发者 https://www.devze.com 2023-03-20 15:53 出处:网络
I have a sectioned table with dynamic number of rows per section. In each cell there is a text field.开发者_高级运维 I need some advice or a nudge in the right direction for: saving text input in the

I have a sectioned table with dynamic number of rows per section. In each cell there is a text field.开发者_高级运维 I need some advice or a nudge in the right direction for: saving text input in the text field after editing is done into a NSMutableArray. .


I am assuming you are setting the table view controller as the text field's delegate somewhere. Based on the comment, you can identify the cell the text field belongs to using,

- (void)textFieldDidEndEditing:(UITextField *)textField {
    YourCustomCell * cell = (YourCustomCell *)textField.superview.superview;
    NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];

    /* Use the index path to store the data in array or dictionary with the index path as key */
}
0

精彩评论

暂无评论...
验证码 换一张
取 消