Piscean
Piscean

Reputation: 3079

How can i dismiss modalViewController without leaving current view?

My application is view based app. First view is login view. After login view i have MainMenuCcontroller which has a tabBarController:

 @interface RunnoMainMenuController : UIViewController {
IBOutlet UITabBarController *tabBarController;
 }

From login view controller, i am going to MainMenuController using this line of code:

 [self presentModalViewController:mainMenu animated:YES];

this controller has 4 tabs. Now i need to do some stuff in viewWillAppear of a tabBarItem. viewWillAppear is not called when i tap a tabBarItem. I have a button in one of those tabBarItem's view which pops up a table view controller using presentModalViewController. This tableView uses dismissModalViewControllerAnimated:YES to disappear it. When i pop up this tableview and dismiss it then viewWillAppear of every tabBarItem works fine. If i will dismiss modalViewController in MainMenuController then it will again go back to login view. How can i dismiss modalViewController without leaving current view or any other solution? Thanks in advance.

Upvotes: 0

Views: 474

Answers (1)

Ashley Mills
Ashley Mills

Reputation: 53092

You may need to consider how your views are presented. The tab bar controller should always be the window's root view controller. From the Apple docs:

When deploying a tab bar interface, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller.

Rather than present your login view as the root view and the tab bar as a modal view controller, try it the other way round. The tab bar controller as root, with the login view as presented as a modal view controller from the view controller of whichever tab is shown initially. Dismissing this will then reveal the tab bar controller.

Upvotes: 3

Related Questions