How to use UINavigationController

Adding a navigationController by code, and add UINavigationBarItem on both left and right hand sides.

FirstViewControllerDelegate.h

#import <UIKit/UIKit.h>
#import "XDreamViewControllerViewController.h"
@interface XDreamAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (strong, nonatomic) XDreamViewControllerViewController *viewController;

@end

FirstViewControllerDelegate.m

#import "XDreamAppDelegate.h"

@implementation XDreamAppDelegate

@synthesize window = _window;
@synthesize viewController=_viewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    self.viewController=[[XDreamViewControllerViewController alloc] initWithNibName:@"Main" bundle:nil];
    UINavigationController *navigationController=[[UINavigationController alloc] initWithRootViewController:self.viewController];
    self.window.rootViewController=navigationController;
    [self.window makeKeyAndVisible];
    return YES;
}

  

  

 

posted @ 2012-05-20 23:43  PH  阅读(115)  评论(0)    收藏  举报