Introduction
In this article we create a single-view application. Here we use one label and three buttons using xib (XCode Interface Builder). In this app, when we click on the first button, the button title color changes and it shows text in the label. The same happens when we click on the second button; the button title color changes and it shows other text in the label, as it is when we click on third button, where again the button title color changes and it shows other text on the label.
Step 1
Open XCode by double-clicking on it.
Step 2
Create a New XCode Project via clicking on it.
Step 3
Now select "Single View Application" and click on Next.
Step 4
Now give your Product Name. Here I use UIView and Company Identifier Mcn Solutions and click on Next.
Step 5
Select the location where you want to save your project and click on Create.
Step 6
Now you will see in the XCode Window six Objective C Classes generated by XCode. When we use a Single View Application, ViewController automatically generate ViewController.h, ViewController.m class or xib correspondence to iPhone/iPad.
1.Appdelegate.h
2.AppDelegate.m
3.ViewController.h
4.ViewController.m
5.ViewController_iPhone.Xib
6.ViewContoller_iPad.Xib.
Here we write code only in the View Controller class.
ViewController.h
ViewController.m
ViewController_iPhone.Xib
ViewContoller_iPad.Xib
Step 7
Click on the File owner icon
Step 8
Connect the button to it's object via linking
As it is done for iPad:
Select action touch up inside
Select which platform you want to see the output for.
Output
Output 1 in iPhone:
Output 2 in iPhone:
Output 3 in iPhone:
Output 4 in iPhone:
Output 1 in iPad:
Output 2 in iPad:
Output 3 in iPad:
Output 4 in iPad: