且构网

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

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

更新时间:2023-11-30 16:49:34

您可以根据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;