Reputation: 1599
I'm trying to go back to the previous view controller and when I go back to this page, I need to reload the view controller. I used viewWillAppaer in the A view controller, but it doesn't work when I call the popViewController
in B view controller.
I used this code in B viewController :
self.navigationController?.popViewController(animated: true)
Upvotes: 0
Views: 1599
Reputation: 826
Are you sure you're presenting the ViewControllers
on a NavigationController
? What could be happening is you're presenting the ViewController
on top of ViewController
A therefor to dismiss it you would need to call dismiss(animated: true, completion: nil)
on ViewController
B.
https://developer.apple.com/documentation/uikit/uiviewcontroller/1621505-dismiss
NavigationController guide: https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/ImplementNavigation.html
Upvotes: 1
Reputation: 7
If you're going to pop a navigation controller, you need to make sure you first pushed the navigation controller onto the navigation stack. Otherwise, you can use
present(UIViewController)
dismiss(UIViewController)
Upvotes: 0