さて、ここに行きます:
@Lefterisと、現在のインデックスを保存するという彼のアイデアに感謝します。インデックスをtag
属性に保存できないため、アクティブを保存しindexPath
、さらにアクティブを保存することにしましたtextField
。(私は知っています、への参照はUITextField
十分だったでしょうが、私は他のもののためにそれを必要としました)
まず、次の2つのプロパティを追加しました。
@property (nonatomic, strong) NSIndexPath *activeIndexPath;
@property (nonatomic, strong) UITextField *activeTextField;
次に、とを実装textFieldDidBeginEditing:
しました。textFieldDidEndEditing:
UITextFieldDelegate
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
NSIndexPath *indexPath = (NSIndexPath*)[self.tableView indexPathForCell:(UITableViewCell*)[[textField superview] superview]];
self.activeTextField = textField;
self.activeIndexPath = indexPath;
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
NSString *input = textField.text;
//assuming values from input textfield into corresponding properties
[self assumeInput:input withIndexPath:self.activeIndexPath];
self.activeTextField = nil;
self.activeTextField = nil;
}
で、メソッドを使用しtextFieldDidEndEditing:
て値をプロパティ(、、など)に保存していself.firstName
ます。self.lastName
[self assumeInput:input withIndexPath:self.activeIndexPath];
私のsaveAction
-Methodでは、現在アクティブなの値を保存していますTextField
。
- (IBAction)saveButtonClicked:(UIBarButtonItem *)sender
{
//assuming input from active field (didEndEditing _not_ called right now!)
[self assumeInput:self.activeTextField.text withIndexPath:self.activeIndexPath];
//test output
NSLog(@"firstName: %@", self.firstName);
NSLog(@"lastName: %@", self.lastName);
NSLog(@"email: %@", self.email);
...
}
... 以上です!
それが役に立てば幸い!@Lefterisの入力に感謝します。
最高、クリス