Press done on the keyboard to close the keyboard.
Select textfields in interface builder, find text input Traits in text field attributes, and set return key to done. OK
Definition Method
-(Ibaction) textfielddoneediting :( ID) sender; // press the done key to close the keyboard
Implementation Method
// Close the keyboard after pressing the done key
-(Ibaction) textfielddoneediting :( ID) sender
{
[Sender resignfirstresponder];
}
Locate the event did end on exit, associate it with textfielddoneediting, and OK.
What if there is no done key for a digital keyboard? Let's close the keyboard by touching the background.
Definition Method
-(Ibaction) backgroundtap :( ID) sender; // close the keyboard by touching the background
Implementation Method
// Close the keyboard by touching the background
-(Ibaction) backgroundtap :( ID) sender
{
[Namefiled resignfirstresponder];
[Numberfield resignfirstresponder];
}
Then select the touch down event of the background and associate it with backgroundtap. OK
In this method, you need to change the uiview to uicontrol.