简体   繁体   中英

Swift 3 : How can I go to the previous ViewController and reload it?

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)

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

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)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM