我正在尝试在 didFinishLaunchingWithOptions
中为 NavigationController
更改 RootViewController
。
但我不知道我该怎么做。
这是我在 didFinishLaunchingWithOptions
中的代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *rootController=[[HomePageController alloc] initWithNibName:@"HomePageController" bundle:nil];
navigationController=[[UINavigationController alloc] initWithRootViewController:rootController];
// presentation=[[PresentationController alloc]initWithNibName:@"PresentationController" bundle:nil];
//
// navigationController=[[UINavigationController alloc]initWithRootViewController:presentation];
//
// presentationList=[[PresentationListController alloc]initWithNibName:@"PresentationListController" bundle:nil];
//
// UINavigationController *listnavigation = [[UINavigationController alloc] initWithRootViewController:presentationList];
//
// revealer=[[ZUUIRevealController alloc]initWithFrontViewController:navigationController rearViewController:listnavigation];
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
return YES;
}
现在我评论然后运行应用程序来更改 rootviewcontroller
。然而,这不是实际的方法。
我们将不胜感激。
最佳答案
取而代之的是:
[self.window addSubview:navigationController.view];
把这个:
self.window.rootViewController = navigationController;
关于iphone - 动态更改导航 Controller 的 rootviewcontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10897489/