ARAV
ARAV

Reputation: 15

Navigation pushViewController is not working

i have login view controller. when usersingin i' showing popup for that i

refereed https://www.youtube.com/watch?v=S5i8n_bqblE i can achieved that. popup had button when i click the button navigation to next view controller but its now working when i am clicking that action is performing but its not navigating to next view controller wher i did mistake

Singin 

class DigitalGateViewController: NANavigationViewController
{

      @IBAction func singin(_ sender: UIButton)
        {
                    let lv = NAViewPresenter().activityVC()
                    self.present(lv, animated: true)
         }

}

 this is popupviewcontroller 

  class ActivityViewController: NANavigationViewController {



    @IBAction func okbuttonclick() {
           let dv = NAViewPresenter().myGuestListVC()
           // self.navigationController?.pushViewController(dv, animated: true)
            }
    }

its not push to textview controller in swift

Upvotes: 0

Views: 3777

Answers (2)

Sanket Ray
Sanket Ray

Reputation: 1141

When you present a view controller, its presented modally and is not pushed onto the previous navigation controller's stack. Hence, you tried to call self.navigationController?.pushViewController(), it doesn't work, because self i.e. NAViewPresenter().myGuestListVC() isn't embedded in a navigation Controller.

If you want to push the new VC onto the previous stack, you will have to dismiss the presented pop up and then push. The easiest way to do this is to use a delegate method.

Edit:

if you want to create a new navigationController, you can do something like this :

let navController = UINavigationController(rootViewController: NAViewPresenter().myGuestListVC())
present(navController, animated: true)

After presenting the navController, you can use self.navigationController.push method henceforth.

Upvotes: 1

Amber K
Amber K

Reputation: 698

The reason why its not pushing because you are presenting it modally not pushing on the navigation stack and so it wont have any navigationController. If you want to push from your modal popup, you can access the property presentingViewController on your modal object and try to push it on navigationController from there.

self.presentingViewController?.navigationController?.pushViewController(myVC, animated: true)
dismiss(animated: true, completion: nil)

Upvotes: 0

Related Questions