Simple ButtonFun Application In iPhone

This is the very simple application, we implement here  a button, when we will press the button it will display the button message. Just have a look.

Step 1: Create a View base application using the template. Give the application name “ButtonFun”.

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: In the ButtonFunViewController.h file, we have added UILabel for displaying the message, and add methods. So make the following changes in the file.

 

 

 

Step 4: Double click your ButtonFunViewController.xib file and open it to the Interface Builder. Drag three Round Rects from the library and place it to the view window, click the three Round Rects and give the name “Addition/Subtraction”, “Division/Multiplication” and “CountNumber” (See the figure below). Now drag Label from the library and place it to the view window. Click the label from the view window and bring up Attribute Inspector change the font size and type into bold. Connect from the File’s owner icon to the label and select display. Now select first Round Rect and bring up connection inspector, drag from the TouchUpInside to the File’s Owner icon select the addsub: action. Select second Round Rect and bring up connection inspector, drag TouchUpInside to the File’s Owner icon and select¬†divisionmultiply: method, do it one more time for third Round Rect and select¬†numbercount: method. Now save the nib file , close it , and go back to the Xcode.

Step 5: In the ButtonFunViewController.m file make the following changes in the file.

 

 

 

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

You can downloaded SourceCode from here ButtonFun 2

Leave a Comment: