I have the following view controllers stack.
First, my app will show an app tour page. (Say TourViewController
- super class is UIViewController
). Added this controller in AppDelegate
as rootviewcontroller.
self.window.rootViewController = tourViewController;
Then from the tour page, if the user taps on "Signin" button, I'm presenting the second view controller (Say LoginViewController
- super class is UIViewController
).
UINavigationController *loginNavigationController = [[UINavigationController alloc] initWithRootViewController:self.loginViewController];
[self presentViewController:loginNavigationController animated:YES completion:nil];
After a successful login, I need to resign the second view controller (LoginViewController
) and want to show a tab bar based view for further needs.
I tried this code inside the login success method.
[self dismissViewControllerAnimated:YES completion:^{
TabBarViewController *tabController = [[TabBarViewController alloc] init];
[self presentViewController:tabController animated:NO completion:nil];
AppDelegate *applicationDelegate = [[UIApplication sharedApplication] delegate];
applicationDelegate.window.rootViewController = tabController;
}];
Problems:
When I'm in the
LoginViewController
, I have two view controllers in my stack. So even I resign theLoginViewController
, the another one (TourViewController
) remains in the screen.If I tried the above code, tab bat controller was successfully added as root view controller. But, when the
LoginViewController
resigns, the background was filled byTourViewController
What I need is, When I resign the LoginViewController
, the background view should be tab bar controller instead of TourViewController
.
Help needed!!