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