且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Appdelegate的Storyboard中以编程方式为UINavigationcontroller设置rootViewcontroller

更新时间:2023-11-30 17:15:16

您可以按照if/else条件使用ViewController创建UINavigationController的对象,并将导航控制器设置为AppDelegate中window的rootViewController属性,如下所示:>

You can create an object of UINavigationController with your ViewController as per if/else condition and set the navigation controller as rootViewController property of window in AppDelegate as follows:

LoginViewController *loginController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"loginController"]; //or the homeController
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:loginController];
self.window.rootViewController = navController;