I have a UIViewcontroller
that presents a popUpView with two buttons, cancel and continue respectively.. but the problem is that when I press the continue button, UINavigationController
is not pushing to the next UIViewcontroller
.. .
-- onNextButtonTapped:
@IBAction func onOkayButtonClicked(_ sender: UIButton) {
self.dismiss(animated: true, completion: {
let nextVC = self.storyboard?.instantiateViewController(withIdentifier: "nextVC") as! NextViewController
// let nextVCNav = UINavigationController(rootViewController: nextVC)
//self.navigationController?.pushViewController(nextVCNav, animated: true)
self.navigationController?.pushViewController(nextVC, animated: true)
})
}
Did miss something?
This seems like a controller chain issue. As from what I understand you must have presented the popup modally and by doing that you have moved out of the UINavigationController
stack. So pushing a view from popupview controller is not an option. You can:
Create a protocol, (or block implementation) that inform viewcontroller
which presented popup, that particular button was clicked (something similar to UIAlertController)
Make a popup as a view inside view controller and show and hide that with animation. That was you can add the action of the button of this popup to your view controller.
I think the UINavigationController is not in hierarchy.
Try this
let nav = UINavigationController(rootViewController: self)
UIApplication.shared.keyWindow?.rootViewController = nav
nav.pushViewController(nextVC, animated: true)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.