Reputation: 63
I have custom UITableViewCell with UITextField. The problem is that i am not able to dismiss that keyboard.
In my TVC i have UITextFieldDelegate and in viewDidLoad method i implement:
customCell.textField.delegate = self;
and of course :
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[customCell.textField resignFirstResponder];
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[customCell.textField resignFirstResponder];
} return NO;
}
i tried implement this code into my CustomTableViewCell class.
Thanks for any help.
Upvotes: 2
Views: 383
Reputation: 45500
You already set the delegate of the textfield.
-(BOOL)textFieldShouldReturn:(UITextField *)textField;
takes a textField
so you didnt need to recreate the cell just to access it because it is being passed to the delegate so use it directly.
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return NO;// or YES depending on what you trying to do
}
Upvotes: 1