Reputation: 5841
Im trying to achieve something similar to Apples Contact.app.
When the user press Edit in the detail view the textfields should become enabled, and when the user presses Done/Save then the input UITextFields should be disabled.
So I added:
-(BOOL) textFieldShouldBeginEditing:(UITextField *)textField {
return [(UITableView*)self.view isEditing];
}
And set the controller to be the delegate for every textfield, but if the users presses Done/Save while editing is taking place the keyboard stays open and the user can edit the string. How can i make sure that this not happens?
Upvotes: 0
Views: 2275
Reputation: 5841
Solved by setting the delegate of the textfield to the cell, and implementing these methods.
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
if (!editing)
[textField resignFirstResponder];
}
- (BOOL) textFieldShouldBeginEditing:(UITextField *)textField {
return [self isEditing];
}
Upvotes: 2
Reputation: 3236
you handled only the beggining of the edit ... you should record which uitextbox is the first responder then if you tap the save button you should invoke a resignFirstResponder on the texbox.
Hope this helps, Moszi
Upvotes: 0