Click Background in iOS to receive keyboard

Source: Internet
Author: User
Tags uicontrol

This time brings you to the iOS click on the background how to pick up the keyboard

Direct:

file:///Users/a504-18/Desktop/Screen shot%202016-03-17%20 pm 7.35.07.png

First create a page like this, and connect the two text boxes:

file:///Users/a504-18/Desktop/Screen shot%202016-03-17%20 pm 7.36.57.png

In fact, it's simple, the view controller has a view property that inherits from Uiviewcontroller. This view property corresponds to the view in the nib file. Using the interface Builder, you can change the class that the object to which the view points to belongs to. Change its underlying class from UIView to Uicontrol. Because Uicontrol is a subclass of UIView, it's great for view properties to connect to Uicontrol instances. If you change from the UIView class creation instance to the Uicontrol class to create an instance, you gain the ability to trigger the action method. But before that, you need to create a method that is required to click on the background.

file:///Users/a504-18/Desktop/Screen shot%202016-03-17%20 pm 7.46.27.png

file:///Users/a504-18/Desktop/Screen shot%202016-03-17%20 pm 7.48.00.png

Select Uicontrol, you need to add an action method in the Controller class, the Uicontrol to connect, generate the following statement:file:///Users/a504-18/Desktop/screenshot%202016-03-17% 20 pm 7.56.50.png

Add the following code to the location above the @end statement in the VIEWCONTROLLER.M file:

file:///Users/a504-18/Desktop/Screen shot%202016-03-17%20 pm 7.57.52.png

This method simply tells two text boxes to discard the first responder state. Even if the control is not the first responder, it is very safe to call the Resignfirstresponder method on it.

Click Background in iOS to receive keyboard

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.