Example of Window-Base Application in iPhone

Every iPhone application has one UIApplication. UIApplication is an IPhone application’s starting point and is responsible for initializing and displaying your application’s UIWindow. It is also responsible for loading your application’s first UIView into the UIWindow. UIApplication has managing your application’s life cycle. UIApplication fulfils this management responsibility using a delegate called UIApplicationDelegate.

Every iPhone application has one UIApplication. UIApplication is an IPhone application’s starting point and is responsible for initializing and displaying your application’s UIWindow. It is also responsible for loading your application’s first UIView into the UIWindow. UIApplication has managing your application’s life cycle. UIApplication fulfils this management responsibility using a delegate called UIApplicationDelegate.

Step 1:Open up your Xcode project , create a new project select Window-Base application and save it.

Step 2:Highlited the Resources folder. Select resource folder -> add -> new file-> interface builder -> view XIB . Give the name and save it.

Step 3:Highlight the classes folder in the Groups & Files. Select File -> New file from the menu , select The UIViewController subclass from the Cocoa Touch Classes. Give the name and save it.

Step 4: Double click the new created .xib file and open it in Interface Builder.Select View from the library and drag -and-drop it into the View window.Highlight File’s Owner and bring up identity inspector, change the class name, whatever you given the class name. example abcViewController some thing like that. Select File’s Owner icon and bring up connection inspector connect view to view icon. Now select the view window and bring up attributes inspector change the color of background.Save the .xib file and go back to the Xcode. 

Step 5: We are now ready to write the code for application.

Step 6: Open the AppDelegate.h file and make the following changes:

#import <UIKit/UIKit.h>
#import "FirstViewController.h"

@interface AddUIViewAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
        FirstViewController *first;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property  (nonatomic, retain) FirstViewController *first;

Step 7: Open the AppDelegate.m file and make the following changes:

- (void)applicationDidFinishLaunching:(UIApplication *)application {
        first = [[FirstViewController alloc]initWithNibName:@"FirstView" bundle:nil];
 
   [window addSubview:[first view]];
   [window makeKeyAndVisible];
}

Step 8: Now compile and run the application. You will observe the following in the simulator.

You can downloaded SourceCode from here AddUIView 2

WP Greet Box icon
Hello there! If you are new here, you might want to subscribe to the RSS feed for updates on this topic, and free programming tips and tricks and source code            snippets.

Leave a Reply

Security Code:

learn iphone programming

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Our Mobile Training Courses

EDUmobile.ORG offers the following 4 Mobile Training Courses. Our iPhone Training Course is very popular, with over 200 developers in training.

learn iphone programming
© 2010 EDUmobile.ORG