We're trying to figure out how to get the keyboard to hide, but we're having problems getting the textFieldShouldReturn
to fire. Why?
This is what has been done:
*.h
@interface MultiSalesViewController : UIViewController <UITextFieldDelegate>
*.c
txtCardNumber.delegate = self; - (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField setUserInteractionEnabled:YES]; [textField resignFirstResponder]; return YES; }
Also, the textField
has its delegate set to Files Owner in Interface Builder. One odd thing, is that the viewController's - (void)textFieldDidEndEditing:(UITextField *)textField
is working.
How to get the hiding of the keyboard working?
Asks the delegate whether to process the pressing of the Return button for the text field.
If you want that text control to stop waiting for input – which in turn dismisses the keyboard – you should call its resignFirstResponder() method, which passes the first responder baton to the next waiting component.
A set of optional methods to manage the editing and validation of text in a text field object.
I had the exact same issue and it was because I forgot to set the delegate for the text field in interface builder to 'files owner'.
I had the same problem and, as Warren Crowther suggested, I managed to solve it by holding down CTRL and dragging from the TextBox to the "File's Owner" label.
(Gosh, I miss Visual Studio sometimes...!!)
(Apologies for repeating what's already been said, but I thought a screenshot might be useful !)
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