我已经设置了一个 UINavigation 控制器,它使用 AppDelegate 作为主要联系点。
我有不同的运行方法,例如 presentHomeViewController、presentLoginViewController,它们将不同的视图控制器推送到导航控制器。
应用程序委托 - didFinishLaunching
welcomeViewController = [[MyWelcomeViewController alloc] initWithNibName:@"MyWelcomeViewController" bundle:nil];
navController = [[UINavigationController alloc] initWithRootViewController:welcomeViewController];
navController.navigationBarHidden = YES;
self.revealSideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:navController];
[self.revealSideViewController setDirectionsToShowBounce:PPRevealSideDirectionNone];
[self.revealSideViewController setPanInteractionsWhenClosed:PPRevealSideInteractionContentView | PPRevealSideInteractionNavigationBar];
self.window.rootViewController = self.revealSideViewController;
这是正确的过程吗?
- (void)presentHomeViewController {
// We start by dismissing the ModalViewConrtoller which is LoginViewController from the welcomeview
[self.welcomeViewController dismissModalViewControllerAnimated:YES];
// Check if the home view controller already exists if not create one
if (!self.homeViewController) {
NSLog(@"presentHomeViewController- Creating the Home View controller");
homeViewController = [[MyHomeViewController alloc] initWithNibName:@"MyHomeViewController" bundle:nil];
}
// Push the homeViewController onto the navController
NSLog(@"presentHomeViewController");
self.navController.navigationBarHidden = NO;
[self.navController setTitle:@"Home"];
[self.navController pushViewController:homeViewController animated:NO];
如果我然后将以下内容添加到不同的类:
[self.navigationController pushViewController:accountViewController animated:NO];
没有视图被推送到堆栈,我应该像我一直在做的那样控制 AppDelegate 中的所有移动,还是有更好的方法来解决这个问题?