Search code examples
iosobjective-cuinavigationcontrolleruitabbarcontroller

How to push viewcontroller from button action on the presented view controller


i have been looking for an answer, can someone please guide me as i have a TabBar Controller with a tableview, Now the scenario is, if the user is not logged in and click on any row then a view controller with a clear color is presented with a small view having a UIButton. Now my TabBar controller is a rootview controller embeded with a navigation controller but when i take action on a presented view controller's UIButton click i am unable to push the login view controller.

TabBarController(Embeded with Navigation controller & also a root view controller) ..> custom pop up view controller with full screen is PRESENTED and when clicked on login button from here .....> i want to push login view controller which can have a back navigation to Tabbar controller.

Can someone please guide me. Thanks in advance.


Solution

  • I believe that you first need to dismiss the current view controller (loginViewController) and in the completion block push the new view controller. So in login view controller, try this:

    let presentingController = self.presentingViewController
    self.dismiss(animated: true) {
        presentingController?.navigationController?.pushViewController(NewViewController(), animated: true)
    }