且构网

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

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

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

您可以根据 if/else 条件使用您的 ViewController 创建一个 UINavigationController 对象,并将导航控制器设置为 AppDelegate 中窗口的 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;