Is there anyway to call textFieldDidEndEditing of UITextField when pressed UIButton?
Current process is function in textFieldDidEndEditing can work when user press "Return" or "Done" button and click on UIButton. To make it clear, if ABC function in textFieldDidEndEditing to be run, user must press "Return" or "Done" button of Keyboard and then click on UIButton.
What I want is I want to run function in textFieldDidEndEditing can work when user press UIButton.
In the button handler method, call:
[self.view endEditing:YES];
This will force the keyboard to disappear and whatever the current text field had the focus will resign first responder and the textFieldDidEndEditing:
method will be called for it.
The above assumes the button handler is in the view controller class.
Since you are dealing with a custom cell and the button is in the custom cell, simply do:
[self endEditing:YES];
where self
is the custom cell. This will resign any text field in the cell.
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