I have a tab bar controlled application.
And I have a flow that goes something like this:-
Tab 1 View Controller (initial view controller) - "presented modally" View controller - "pushed" View Controller 2 - "pushed" View Controller 3 - "presented modally" View Controller 4
Basically, it is Modal - Push - Push - Modal
Now, I want to go back to Tab 1 View Controller(initial view controller) from View Controller 4 (that was presented modally).
View controller 4 should have a "back button" which when pressed will lead me back to Tab 1 View Controller.
How do I do that? I tried:-
Creating a whole new
UIWindow
and placed things back. Problem is the back button which I placed on View Controller 4 comes back on Tab 1 View Controller. Weird. Tried removing it with various methods, didn't go away.Use the
popToViewController
method, but the navigation controller is different because of last modal view controller.
Any clues on how to solve this?
Okay so I solved it. I needed to climb back down the ladder.
Dismiss
self.navigationController.presentingViewController.presentingViewController
, which was pointing toUITabBarController
, whereself.navigationController
is from View Controller no. 4 (the last modal view controller).