First enter finish and press done on the keyboard to turn off the keyboard
First in Interface Builder select Textfields, and then in the text Field attributes found text Input Traits, select Return key for done. Ok
Defining methods
Copy Code code as follows:
-(Ibaction) textfielddoneediting: (ID) sender; Press the done key to close the keyboard
Implementation methods
Copy Code code as follows:
Turn off the keyboard after the done key is pressed
-(Ibaction) textfielddoneediting: (ID) sender
{
[Sender Resignfirstresponder];
}
Then find the event did end on Exit, associate with Textfielddoneediting, OK.
If it is a numeric keypad, do not have the done key to do it, we touch the background to close the keyboard
Defining methods
Copy Code code as follows:
-(Ibaction) Backgroundtap: (ID) sender; Turn off the keyboard by touching the background
Implementation methods
Copy Code code as follows:
Turn off the keyboard by touching the background
-(Ibaction) Backgroundtap: (ID) sender
{
[Namefiled Resignfirstresponder];
[Numberfield Resignfirstresponder];
}
Then select the context of the touch down event, associated Backgroundtap,ok
One thing to note about this approach is to change the UIView to Uicontrol.