Develop the first ios6.0 application (helloworld) in xcode4.5)Add a keyboard discard event to the text box
Step 1: Read the first part of this blog as follows:
Develop the first ios6.0 application (helloworld) in xcode4.5)
Step 2: start coding
Add the following to the viewcontroller. h file:Code
// Add the interface to discard the keyboard event-(ibaction) textfiledoneediting :( ID) sender;
Add the following code to the viewcontroller. M file:
// Add the discard keyboard event implementation-(ibaction) textfiledoneediting :( ID) sender {[Sender resignfirstresponder];}
Then add the event we wrote to the text box link.
Finally, we successfully implemented the text box to discard the keyboard event and click on the keyboard.ReturnYou can discard the keyboard.
Advanced: Click anywhere to discard Keyboard Events (note)
Step 1: start coding
Add the following code to the viewcontroller. h file:
// Touch the background to close the keyboard interface-(ibaction) backgroundtap :( ID) sender;
Add the following code to the viewcontroller. M file:
// Touch the background to disable the keyboard implementation-(ibaction) backgroundtap :( ID) sender {// The variable should discard the keyboard at this time, when binding, note that it is associated with the view of the Background [textfield resignfirstresponder];}
Note that when binding events, we find that the view object does not have a touch event, so we mustChange the original uiview inheritance to uicontrol.In this way, we can connect the touch event.
The connection method is the same as the above text discard keyboard, and the same method is used for connection.