Keyboard will not be closed with UITextField

In my code, I have:

-(BOOL)textFieldShouldReturn:(UITextField*)theTextField{ if (theTextField == ITload) { [ITload resignFirstResponder]; return YES; } if (theTextField == FacilitiesLoad) { [FacilitiesLoad resignFirstResponder]; return YES; } return NO; } 

ITload and FacilitiesLoad are my text fields too. I am using Numerical with a punctuation keyboard and the key is not displayed. I have a return key that does not close the keyboard.

Any ideas on how to display the finished key and get the text FieldShouldReturn work?

0
source share
1 answer

It seems that you have not set the delegate of your text fields to your receiver.

 ITLoad.delegate = self; FacilitiesLoad.delegate = self; 

EDIT: You get warnings because your view controller (formally) does not conform to the UITextFieldDelegate protocol. Declare it as follows:

 @interface MyViewController: UIViewController <UITextFieldDelegate> { } 

and etc.

+3
source

Source: https://habr.com/ru/post/975180/


All Articles