首页 > 代码库 > ios navigationController代码创建

ios navigationController代码创建

1.新建类文件FirstViewController,subClass of:UIViewController

2.新建类文件MYNavigationController,subClass of:UINavigationController

3.AppDelegate.m中包含以上两个头文件,然后在didFinishLaunchingWithOptions写

FirstViewController *viewController = [[FirstViewController alloc]initWithNibName:nil bundle:nil];

    MYNavigationController *navigationController = [[MYNavigationController alloc]initWithRootViewController:viewController];

    self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];

    self.window.rootViewController = navigationController;

    self.window.backgroundColor = [UIColor whiteColor];

    [self.window makeKeyWindow];

    return YES;

 

4.返回按钮设置

 //返回按钮

    UIBarButtonItem *Return = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemReply target:self action:@selector(pop)];

    self.navigationItem.leftBarButtonItems = @[Return];

 

ios navigationController代码创建