Programmatically creating UINavigationController in iOS

前端 未结 7 2178
孤街浪徒
孤街浪徒 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:27

    So for creating a UINavigationController programatically without using storyboards, go to your app delegate and do the following. Create two properties, window and viewController

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        self.window.backgroundColor=[UIColor clearColor];
    
        self.viewController = [[YourFirstViewController alloc] initWithNibName:@"YourFirstViewController" bundle:nil];
        UINavigationController *navController=[[UINavigationController alloc]initWithRootViewController:self.viewController];
        self.window.rootViewController = navController;
        [self.window makeKeyAndVisible];
    
        // Override point for customization after application launch.
        return YES;
    }
    
    0 讨论(0)
提交回复
热议问题