I am using in my programatically made uitextfield
-(BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
to catch an event that my textfield is done editing.In events that i change the focus from one text field to another or press return ,the event is fired,but if i am in a textfield and click another uicontrol like a button from it ,this method is not fired.what is wrong here...i need to catch every event when a user has done editing a textfield. i tried with textfielddidendediting
too but this event is missed..How to overcome this
when you click on button .write code in - (IBAction) method
[yourTextField resignFirstResponder]; then those method will get called.
- (IBAction) yourBtnClicked:(id)sender
{
[textField resignFirstResponder];
}
What happens here is that when you are editing a textfield and then you click on a UIButton or anything else then the delegate methods for UITextfield will not be called.
For that, you'll have to write the code for that textfield inside the code for that button.
All you need is,
//inside your btn action
- (IBAction) btnPressed : (id) sender
{
[self textFieldDidEndEditing:myTextField];
//remaining code goes 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