IOS10 UI Tutorial Disabling view interaction with users

Source: Internet
Author: User

iOS10 UI Tutorial Disabling view interaction with users

In the above we mentioned the use of the Ishidden property and the Alpha property to enable the interaction of the view with the user is disabled, in addition to this feature can also use the UIView isuserinteractionenabled property implementation, the syntax is as follows:

var isuserinteractionenabled:bool {Get Set}

  

This property can receive a Boolean value, and when the received Boolean value is false, the interaction of the view with the user is disabled.

"Example 1-2:isuserinteractionenabled" disables the interaction of the text box with the user. The following steps are described:

(1) Create a single View application template type project, named Isuserinteractionenabled.

(2) Open the Main.storyboard file and drag the Text field textbox from the View library to the view controller's main master.

(3) Add the Text field to the TextBox declaration and the associated socket variable TextField.

Note: Run the program at this point, and when the developer taps the text box, you'll see a blue cursor appear in the text box, and the keyboard appears at the bottom of the screen, as shown in 1.6.

(4) Open the Viewcontroller.swift file, write the code, disable the text box interaction with the user. The code is as follows:

Import Uikitclass Viewcontroller:uiviewcontroller {    @IBOutlet weak var textfield:uitextfield!    Override Func Viewdidload () {        super.viewdidload ()        //Do any additional setup after loading the view, typically fro M a nib.        Textfield.isuserinteractionenabled=false                                               Disable text box interaction with the user    } ...}

  

Now that the program is running and the main interface of the application appears on the emulator, tap the text box and there will be no response at this point, as shown in 1.7.

Figure 1.6 Run effect figure 1.7 run effect

IOS10 UI Tutorial Disabling view interaction with users

related reading : iOS10 UI Tutorial Base Changing the look of a view and the visibility of a view

IOS10 UI Tutorial Disabling view interaction with users

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.