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;
}

浙公网安备 33010602011771号