IOS App Development. IOS Application Input & Output.

 Make a simple application right now! There will be a text field. There will be a button. And there will be a level. Enter your name in the text box. And by clicking on the name and pressing the button, your name will appear on the level. To create an entire application, we just need to write one line of code. Then let's get started.

IOS Application
IOS Application

First open the project and open the project. In the Project Navigation section, select a storyboard.

Now drag a text box from the object library and paste it into the storyboard. Object Library in the lower right corner.

Check the placeholder in the textbox. A placeholder is a message for text fields, a suggestion of what to write in the text field. For example, we can enter a name by typing in a text field in our application. So the placeholder might write: Enter your name

Drag the button like a text box and drag it to the label board.

Now we need to write the code. Before we write code, we need to add controllers to our view. One view of one of the Story Boards is one view. The iOS application runs in MVC mode. The following text can be seen to know what is MVC

Brief information about MVC/Model-view-controller

The storyboard is our view file. And our default controller is the ViewController.swift file. To add a view to a controller, we save a storyboard and a ViewController.swift file. To do this, click on the Show Assistant Editor button in the upper right corner. See picture below:

When the button is clicked, the text from our TextField will be read and it will appear in the level. And it's a promotion, isn't it?

Select the button, press the Ctrl key and drag it into the ViewController.swift file. And class ViewController: UIViewController {leave after. Then a popup window will open

Pay attention to the picture above. The popup connection will be selected by default as the output. If you are changing outlet, select Action. Let's say a name in the name field. This is the name of the method. Then a method will be added to ViewController.swift. If we write the line code inside this method, our application will work correctly. The method or function below will be added.

Name (sender: AnyObject) {

}

We have just added a button to the ViewController.swift file. The text field and label will still be added. The text field and the label are one output.

First, select the text field and drag it into the ViewController.swift file by pressing Ctrl + Ctr + . Let's try dragging the getName/Button method. I mean function @IBAction getName (sender: AnyObject) and class above ViewController: UIViewController { leave after. Then a pop-up window will open. By default Connection will be selected as Outlet. And the text field is an outlet, so it doesn't need to be changed. Call this outlet by name. how i made textfield

In the same way, we add the Label and ViewController.swift files. Just like I gave my field

Now write in the method

1

myLabel.text = "You typed:" + textField.text!

TextField.text has been written to the text of the TextField. We know about adding string or string concatenation. If you don't know, you can learn from the quick basics. You have "Your name" in the text field text. And at the end it is set to myLabel. Simple.

Run the application and after typing in the text box, click the button. Then we will see that our application works great. We have just created an application that we wanted to create an application.

0 Comments