I'm having troubles with an UINavigationController
which viewControllers
property is null
after tapping Back on a previously pushed view controller.
The root view controller in AppDelegate
is defined with that code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
StartViewController *startVc = [[StartViewController alloc] initWithNibName:@"StartViewController" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:startVc];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
return YES;
}
At StartViewController
I'm hiding the navigation bar within - (void)viewWillAppear:(BOOL)animated
where I've also a UIButton
instance where I push the next view controller when tapping with that code:
- (IBAction)buttonTapped:(id)sender {
PhilosophyViewController *philsophyVc = [[PhilosophyViewController alloc] initWithNibName:@"PhilosophyViewController" bundle:nil];
[self.navigationController pushViewController:philsophyVc animated:YES];
}
I'm heading over to the next view as expected. But when tapping the Back button at the navigation bar, the previous view (StartViewController
) is empty and when checking the viewControllers
property of the navigation controller - it is null?
Any idea?
Thanks in advance.
self.navigationController
after going back. Just becauseself.navigationController.viewControllers
isnil
does not necessarily mean thatnavigationController
is not nil. – Craig OtisviewWillLoad
inStartViewController
code. – thedom