In iOS application development, there are three types of view objects open the virtual keyboard, input operations, but how to turn off the virtual keyboard, but does not provide an automated method. This needs to be achieved on our own.
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
The code is as follows:
-(Ibaction) textfielddoneediting: (ID) sender; Press the done key to close the keyboard
Implementation methods
The code is 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
The code is as follows:
-(Ibaction) Backgroundtap: (ID) sender; Turn off the keyboard by touching the background
Implementation methods
The code is 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.