ViewBase application in iPad

This is the simple View Base application. In this application we will display image,  button and label.

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

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: Xpand classes and notice Interface Builder created the ViewBase_iPadViewController class for you. Expand Resources and notice the template generated a separate nib,ViewBase_iPadViewController.xib, for the “ViewBase_iPad”.

Step 4: In the ViewBase_iPadViewController.h file, we have created instance of UILabel and UIImage class. Define one IBAction method. So make the following changes.

#import <UIKit/UIKit.h>

@interface ViewBase_iPadViewController : UIViewController {
       
 IBOutlet UILabel *myLabel;
 IBOutlet UIImage *myImage;

}

@property(nonatomic,retain) IBOutlet UILabel *myLabel;
@property(nonatomic,retain) IBOutlet UIImage *myImage;

(IBAction)ButtonPressed:(id)sender;

Step 5: Double click the ViewBase_iPadViewController.xib file and open it to the Interface Builder.First drag the Image View from the library and place it to the View window. Next drag label and Round Rect from the library and place it to the view window. Select the Round Rect from the view window and bring up Connection iNspector. Drag from the Touch Up Inside to the File’s Owner icon and select ButtonPressed: method. Connect File’s Owner icon to the View icon and select view and connect File’s Owner icon to the label select myLabel. Now save the ViewBase_iPadViewController.xib file, close it and go back to the Xcode.

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

(IBAction)ButtonPressed:(id)sender{

myLabel.text = @"Welocome to the Real World!!!";
}

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

You can Download SourceCode from here ViewBase_iPad

Leave a Reply

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