Touching the Background to close the Keyboard

Can you recall that Apple's IOS applictions do in this situation?

cause the keyboard to go away.

our view controller has a property called view that it inherited from 

UIViewController. this view corresponds to the View icon in the nib file

this property points to an instance of UIView in the nib that acts as a container for all the items in our user interface

has no appearance but it covers the entire iphone window.

container view  to simply hold other views and controls.

is the background of our user interface.

change the class of the object that view points to so that its underlying classs is 

UIControl instead of UIView.

UIControl is a subclass of UIView.

change the underlying classs of our nib's view.

nib's main window in icon view mode, 

single click the view icon and press c4 to bring up the identity inspector

The field labeled Class currently says UIView

change it to read UIControl.

subclasses of UIControl.

by changing the underlying class, we have just given this view

the ability to trigger action methods.

You can verify this by pressing c2 to bring up the connections inspector 

原文地址:https://www.cnblogs.com/yushunwu/p/2682724.html