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 "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:
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










