I have a situation that need to judge a invalid session and present the loing view controller.Now, after I get the message from server. I judge the statuscode . If it is a session error, I post a notification. The rootviewcontroller will handle the notification. Here is my Code in rootviewcontroller:
- (void)handleInvalidSessionNotification:(NSNotification *)notification{
UINavigationController * tmpController = self.navigationController;
[tmpController popToRootViewControllerAnimated:NO];
LoginViewController * loginViewController = [[LoginViewController alloc] init];
UINavigationController * naviController = [[UINavigationController alloc] initWithRootViewController:loginViewController];
naviController.navigationBarHidden = YES;
[self.navigationController presentModalViewController:naviController animated:YES];
}
Initially it did not work. I found this link UINavigationController popToRootViewController, and then immediately push a new view , and change the Code:
UINavigationController * tmpController = self.navigationController;
[tmpController popToRootViewControllerAnimated:NO];
It works, but no animations, do someone have a solution or suggestion…. Thanks for your help
I wonder why you don’t simply push your viewController on your existing navigationController. Maybe like this: