How do I pull a control inside a main.storyboard in Xcode and implement a simple effect? I just contact Swift language soon, for the operation of the IDE is very unfamiliar, do not understand the online reference on the online predecessors of the article. I'll show you how to use the Swift language with Main.storyboard to demonstrate a small example of a new Singleview application here.
The created application has automatically created a well-connected viewcontroller with Main.storyboard.
Next we add a Uitextfield and UIButton to the view within the Main.storyboard
Click the second button (two circles) in the upper-right corner of the editor to display the view and code on both sides
Next will be associated with the control and code, put the mouse on the uitextfield above the CTRL key and drag the mouse to the Viewcontroller.swift file gouges will appear after the following screen to enter the name,
The same method pulls the button over.
Now when the button event is bound, the following screen will appear when you select the buttons and click the first button (arrow) in the top right corner of the editor.
After you move the mouse over the small circle to the right of Touch up InSide, a plus sign appears and then you can bind the method by holding down the left mouse button and dragging to the empty area of the Viewcontroller.swift file, and write a few lines of code in the method body.
@IBAction func btnclicked (sender:anyobject) {
Let Alertview = Uialertview ()//Define a popup box
Alertview.title = "System Info"
Alertview.message = "Your Name is \ (txtname.text)"
Alertview.addbuttonwithtitle ("OK")
Alertview.show ()
}
After running inside the simulator, after entering the name in the text box, click the button effect as shown:
Use Main.storyboard to pull in controls and implement events in Xcode (Swift language)