I’m doing form validation on my iPhone app. I want to call the didEndEditing method on my button submit. How do I do this?
Here is my code
This is the method
-(void)didEndEditing:(UITextField*)textField;
{
// Do Something!
}
Here I’m calling the method
-(IBAction)btnSelected:(id)sender {
UIBarButtonItem *bbi = (UIBarButtonItem *) sender;
if (bbi.tag == 1) {
[self didEndEditing]; // How do I call this method?
}
}
Can someone help me?
I assume your refering to
textViewDidEndEditing:? you should not call that method yourself it will be called when the text field is not the first responder anymore. From the API documentation:If you want validate I suggest that you refactor out the validation code and call it from both
textViewDidEndEditing:and submit.You can loop thru all text fields like this:
If you need different validation per field you could make a more complex data structure that includes validation block, regex etc for each field.