Hide the keyboard after entering the text box.
Two ways to hide a virtual keyboard
After entering information in the text box, hide the keyboard;
Two methods: the first one is to press the return key to hide the keyboard. The second is to press the blank area on the screen to hide the interface.
Implementation Method:
Method 1: Add Action to the text box, select Did End On Exit as the event type, and add logical code to the implementation method;
Method 2: To touch the background, first modify the background class. By default, UIView does not respond to the event and is changed to UIControl, which is its subclass. Then, add the action backgroupTap and set the event type to TouchDown;
The implementation code is as follows:
. H file added output port and action
-(IBAction) textDoneExiting :( UITextField *) sender;
@ Property (weak, nonatomic) IBOutletUITextField * txtName;
@ Property (weak, nonatomic) IBOutletUITextField * txtCode;
Added implementation logic to the. m file;
-(IBAction) textDoneExiting :( UITextField *) sender {
[Sender resignFirstResponder];
}
-(IBAction) backgroupTap :( UIControl *) sender {
Using self.txt NameresignFirstResponder];
[Self.txt CoderesignFirstResponder];
}