IOS7 Click on the blanks to hide the keyboard in several ways, as follows:
iOS development often use the input box, by default, click the input box will eject the keyboard, but must implement the input box return delegate method to cancel the keyboard display, for the user experience is very unfriendly, we can click on the keyboard outside the blank area to hide the keyboard, I've summed up several ways to hide the keyboard below:
First, there are two ways that you can hide the keyboard:
1. [View Endediting:yes] This method allows the entire view to cancel the first responder so that the keyboard of all controls is hidden.
2, [textfiled Resignfirstresponder] This is more commonly used to let a textfiled keyboard hidden.
Then there are several ways to implement it:
The first: using View's Touchesbegan: Touch events to achieve the hidden keyboard, when clicked View area will trigger this event
-(void) Touchesbegan: (Nsset *) touches withevent: (uievent *) event{
[textfiled Resignfirstresponder];
The second type: Create a custom touch gesture to hide the keyboard:
-(void) viewdidload
{
[super viewdidload];
UITapGestureRecognizer *tapgesturerecognizer = [[UITapGestureRecognizer alloc] initwithtarget:self action: @selector ( Keyboardhide:)];
Setting to no indicates that the current control will propagate to other controls when it responds, and the default is yes.
Tapgesturerecognizer.cancelstouchesinview = NO;
Add a touch event to the current view
[Self.view Addgesturerecognizer:tapgesturerecognizer];
}
-(void) Keyboardhide: (uitapgesturerecognizer*) tap{
[textfiled resignfirstresponder];
}
The Third: Modify xib UIView custom class for Uicontrol,uicontrol is a common control such as UIButton's parent class, a derived class of uiview that implements the encapsulation of touch and down.
1, first set the Xib UIView custom class for Uicontrol
2, set the relationship event, the Xib UIView dragged to the. h Area
Set a good event for touch up Inside
3, write hidden code:
-(Ibaction) Touchview: (ID) Sender {
[self.view endediting:yes];
OK, these are three kinds of more commonly used hidden keyboard methods, each can be used for different occasions and its advantages and disadvantages, see how to use.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.