Background
To add new view to the Empty application without using UINavigationController.
To add new view to the Empty application without using UINavigationController.
PART - 1 Create new [Empty Application] project using Xcode 4.x
(Below demo is based on ver. 4.5.2)
1.1) Start Xcode to create new project

1.2) Select [Empty Application] template from [iOS][Application] 


1.3) Provide project name [DemoMultipleView] and other information
1.4) XCode will create necessary project structure based on selected template called [Empty Application]

1.5) Run newly created application on simulator [Command + R]
(Simulator will display Blank Screen, because View does not in this project)
(Menu Reference: The Object Library is available under menu [View][Utilities][Show Object Library])

2.6) Make newly added ViewController as a RootController by modifying Application Delegate
[AppDelegate.m]
Change From


1.5) Run newly created application on simulator [Command + R]
(Simulator will display Blank Screen, because View does not in this project)

PART - 2 Add new View along with UIViewController, which is responsible for controlling the View behaviour. (Add View along with UIViewController, which is responsible for controlling the View behaviour.)
2.1) From Xcode menu select [File][New][File...] or [Command + N]
2.2) Select [iOS][Cocoa Touch][Objective-C class]
2.3) Select [Subclass of] [UIViewController] and make select check box [With XIB for user interface]
- New view controller class will be created [DemoViewController]
- DemoViewController is subclass of [UIViewController]
- XIB option will create new View file called [DemoViewController.xib]
2.4) Xcode will create below 3 files; header [.h], implementation [.m] and view [.xib]
2.5) Open view file [DemoViewController.xib] and add [Label] by dragging from [Object Library]
(The Object Library is available under menu [View][Utilities][Show Object Library])

2.6) Make newly added ViewController as a RootController by modifying Application Delegate
[AppDelegate.m]
Change From
- (BOOL)_application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
Change To
#import "DemoViewController.h"
//Change above method as below
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
DemoViewController *demoViewController = [[[DemoViewController alloc] init] autorelease];
[self.window setRootViewController:demoViewController];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
2.7) Run the application on simulator to display newly added view [DemoViewController.xib]






No comments:
Post a Comment