Programmatically creating UINavigationController in iOS

前端 未结 7 2187
孤街浪徒
孤街浪徒 2020-12-09 22:54

I am new to iOS. And I want to use navigation controller in my application but I have no any idea how to do it. So can any one guide me step by step for creating navigation

7条回答
  •  爱一瞬间的悲伤
    2020-12-09 23:20

    Here is the code that you should write in app delegate.

    UIViewController *vc=[[UIViewController alloc]initWithNibName:@"vc1" bundle:nil];
    UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 568)];
    view.backgroundColor=[UIColor redColor];
    [vc setView:view];
    
    self.navme=[[UINavigationController alloc]initWithRootViewController:vc];
    self.window.rootViewController = self.navme;
    

提交回复
热议问题