Latest News & Reviews

IOS Application InPut & OutPut . IOS App Development .

Make a simple app now! There will be a text field. There will be a button. And there will be a level. Tell us your name in the text field. And by clicking the name and clicking on the button, your name will appear on the level. To create the whole app we just need to write one line code. Then let’s start.

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

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

Inspect a placeholder in the text field. Placeholder is a message for text fields, a suggestion for what to write in the text field. Like we can input a name by typing text field in our app. So, the placeholder can write in: Type your name

Drag a button like a text field and drag it to an Label Story Board.

Now we have to write the code. Before writing code, we need to add controllers to our view. One view of one of the Story Board is one view. The iOS app works in MVC mode. The following text can be seen to know what MVC is

Brief idea about MVC / Model-view-controller

Storyboard is our view file. And our default controller is ViewController.swift file. To add a view to the controller, we will retain the storyboard and the ViewController.swift file. For that, click on the Show Assistant Editor button in the upper right corner. See the picture below :

Clicking on the button will read the text from our TextField text and it will appear in the Level. And this is an action, is not it?

Select the Buton and press the Ctr key and bring it inside the ViewController.swift file. And class ViewController: UIViewController {leave it after. Then a pop-up will open

Notice the picture above. Pop-up Connection will be selected by default as an Outlet. If you change the outlet, select Action. Let’s name 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 a line code inside this method our app will work properly. The method or function below will be added.

@IBAction func getName (sender: AnyObject) {

We just added the button to ViewController.swift file. Text field and label will still be added. Text field and label are one outlet.

First select the text field and drag it to the ViewController.swift file by pressing Ctrl + Ctr +. Lets try to drag on the getName / Button’s method. Mean @IBAction func getName (sender: AnyObject) and above class ViewController: UIViewController {leave it after. Then a popup will open. By default, Connection will be selected as an Outlet. And textfield is an outlet, so it does not have to change. Give this outlet a name by name. Like I did textField

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

Now write in the method

myLabel.text = “You typed:” + textField.text!
TextField.text has been written in the TextField text. We know about adding strings concatenation or strings. If you do not know, you can know from swift basics. You’ve got ‘You’r’ name ‘in the text field text. And at the end, it’s set to myLabel. Simple.

Run the app, and by typing some text in the text field press the button. Then we will see that our app works beautifully. We just created an app that we wanted to create an app.

Leave a Reply

Your email address will not be published. Required fields are marked *

MovieBazar.Info © 2018