Build your first iPhone application

In this tutorial , we will start building our first iPhone application. Open Xcode and start a new project . Fill in the Project Name and choose a destination to save your project .  After completion of the process you will see this screen .





























Now, From the navigator area on the left side of the main window, select Main.storyboard.

An empty ViewController will appear on the editor area. This is the place where we do our designing part.

1) Click on the top of empty ViewController area .

2) Select Show Attribute Inspector from the utility area which is on the right side of the main window.




























3) In the simulated metrics , select iPhone Size. (I have selected iPhone 4 inch)

4) Then in the bottom of the utility area , write UILabel. This will search the UILabel . 

5) Select UILabel And Drag it in the ViewController. (UI is User Interface)





























6) Rename the label from the utility area and you can play around with its properties like text color, font size etc.

7) Now add a UIButton as we have added UILabel.

8) Now we need to connect our Main.storyboard with the ViewController implementation file. To do this click on Show the assistant editor  button on the right hand side of the toolbar.

It gives us the spit view where we see the ViewController.m file. We need to connect the storyboard with the viewController. For making the connection ,just right click and hold on the UILabel and drag it underneath the @interface ViewController ()



9)  i) A pop up will appear in which we have to select Outlet in Connection 
     ii) Give name to uiLabel.
     iii) Click on connect

This will link our UILabel to the viewController.m file.























10 ) Do same to connect UIButton to the ViewController. But button always performs some action , So change the Connection to Action in the popup menu.

Give button a name .(I named it Click)
Select Event to Touch Up Inside.
Click on Connect.




















11 )  UIButton method will be created automatically . Now just add this line to change UIlabel name on button click


- (IBAction)click:(id)sender {
    
    _myLabel.text = @"My Button work`s";

}

Here , _myLabel is the name of my Label and it will change the name from my label to My button work`s.


12) Run your simulator by command+r or windows+r (for windows) or click on the run button in the toolbar .
Your First app has been created.




Thank you... :) 

Comments

Popular Posts