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 know how to allow for in-place text editing of cell?
Also can this value be used with Core Data i.e. can it be persisted..
The thing that I am looking for can be seen under Settings -> Wi-fi, where you see those fields Domain, Client, IP, etc where the values can be set in the same place.
Also are there are any downside of using In-place editing Vs having a separate view controller to control a field value?
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 */
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With