Create View-Base Application In iPhone

We are going to define view-base application template that we use in the application. We will see how the view and controller objects work together in an iPhone application.

Step 1: Create a View-base application using the template . Name the project SimpleExample.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Expand classes and notice Interface Builder created the SimpleExampleViewController class for you. Expand Resources and notice the template generated a separate nib, SimpleExampleViewController.xib for the SimpleExampleViewController.

Step 4: Open SimpleExampleViewController.h and add UILabel and one method for changing the label’s value. Make the label IBOutlet and method an IBAction. Make the following changes in the SimpleExampleViewController.h file.

 

 

 

Step 5: Open SimpleExampleViewController.xib file in the Interface Builder. Select library from the Tool menu and drag label from the library and place it to the view window, double click it and change the label name into “Hello iPhone!!!” . Now bring the Round Rect from the library and place it ¬†below of the label. Double click the Round Rect and give the name “ClickMe” . Now single click the Round Rect and ¬†bring up connection inspector, drap from the Touch Up Inside to the File’s Owner icon and select the ¬†changeLabelValue: action. Save your .xib file and go back to the Xcode.

Step 6: Open the SimpleExampleViewController.m file and make the following changes:

 

 

 

Step 7: Now compile and run the application in the simulator.

You can downloaded SourceCode from here SimpleExample 2

Leave a Comment: