self.dismiss(animated: false) {
let vc = self.storyboard?.instantiateViewController(withIdentifier: "ViewController") as! ViewController
self.navigationController?.pushViewController(vc, animated: false)
}
Asked
Active
Viewed 42 times
-1
![](../../users/profiles/5508175.webp)
Andrew
- 18,946
- 6
- 54
- 66
![](../../users/profiles/11068357.webp)
Rizwan Mehmood
- 88
- 3
1 Answers
0
self.navigationController will only have a value if your ViewController is embedded in an UINavigationController otherwise it will be nil. In your case it is nil, so your controller is dismissed successfully but ViewController is not pushed.
In your completion block use self.presentingViewController to push the object.
self.dismiss(animated: false) {
let vc = self.storyboard?.instantiateViewController(withIdentifier: "ViewController") as! ViewController
self.presentingViewController?.navigationController?.pushViewController(vc, animated: false)
}
![](../../users/profiles/7425588.webp)
udbhateja
- 751
- 4
- 15
-
that's not work. current controller dismiss but not navigate to other – Rizwan Mehmood Oct 11 '19 at 08:32
-
Just print(self.presentingViewController?.navigationController) and check it has a value or not. – udbhateja Oct 14 '19 at 04:30