Can someone please show me an example of in-place editing of UITableView cell...I am aware of UITableView delegate methods like cellForRowAtIndexPath,...etc
But I do not
Add a UITextField
to your cell.
Either way you choose to edit an entry, whether your using CoreData, or whatever to store the info, you need someway to save it. If you go the on-Table editing method, you can use the textField delegates to save the data as the user hits return.
In your cellForRowAtIndexPath
:
myTextField = [[UITextField alloc] initWithFrame:CGRectMake(0,10,125,25)];
myTextField.adjustsFontSizeToFitWidth = NO;
myTextField.backgroundColor = [UIColor clearColor];
myTextField.autocorrectionType = UITextAutocorrectionTypeNo;
myTextField.autocapitalizationType = UITextAutocapitalizationTypeWords;
myTextField.textAlignment = UITextAlignmentRight;
myTextField.keyboardType = UIKeyboardTypeDefault;
myTextField.returnKeyType = UIReturnKeyDone;
myTextField.clearButtonMode = UITextFieldViewModeNever;
myTextField.delegate = self;
cell.accessoryView = myTextField;
TextField Delegates
:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
if(textField == myTextField){
/* do your saving here */
}
}