self.navigationController is nil second time ViewController is loaded
ios, ios6, objective-c, uinavigationcontroller, uiviewcontroller
Solution
I think you might have already resolved this but i encountered the exact same thing. And I think we might be doing the exact same thing like using facebook for login. Anyway for some one else in the future this might be useful. The issue that i had that i was re allocating the UINavigationController again when coming back from background on a failure condition.
So what you can do is try to put a breakpoint around the place where you initialise your rootViewController for the UiNavigationController.
[[UINavigationController alloc]
initWithRootViewController:viewController]; and make sure that you do re-initailise your UINavigationController if you have already done it.
Problem
I have a delegate/handler that i have implemented on my UIViewControllers to handle timeouts to the a remote webservice. When a request is made to my webservice, and a timeout http code is returned, the delegate is called and performs the following: ``` UINavigationController *navController = self.navigationController; if (navController) { [navController popToRootViewControllerAnimated:YES]; } else { NSLog(@"navController is null/nil"); } ``` If I do the following steps, `navController` is instantiated correctly and the `popToRootViewController` action occurs. - Authenticate my app with the webservice on a Login ViewController - Auto trigger a segue to a CustomMenuViewController - Wait for the webservice to timeout remotely - Click to trigger a segue to CustomSubMenuViewController Now, if i do the following steps, the else clause in the above code block is triggered because for some reasons navController isn't being set correctly: - Authenticate my app with the webservice on a CustomLoginViewController - Auto segue to a CustomMenuViewController - Immediately click to trigger a segue to CustomSubMenuViewController - Click back button to trigger a pop - Wait for the webservice to timeout remotely - Click to trigger a segue to the same CustomSubMenuViewController My question is: why when i load a ViewController for the second time, does self.navigationController return null? The call stack in the above example should look like this: `NavigationController -> CustomLoginViewController -> CustomMenuViewController -> CustomSubMenuViewController` Thanks UPDATE: Still haven't made any progress on this issue!