Swift: Reload a View Controller

后端 未结 8 946
南旧
南旧 2020-12-15 02:41

I need to refresh a view controller when a certain button is tapped. Simply activating viewDidLoad() does not seem to be working for what I need to

8条回答
  •  庸人自扰
    2020-12-15 03:20

    View Life Cycle

    it will load ViewWillAppear everytime you open the view. above is the link to the picture View Controller Lifecycle.

    viewWillAppear()—Called just before the view controller’s content view is added to the app’s view hierarchy. Use this method to trigger any operations that need to occur before the content view is presented onscreen. Despite the name, just because the system calls this method, it does not guarantee that the content view will become visible. The view may be obscured by other views or hidden. This method simply indicates that the content view is about to be added to the app’s view hierarchy.

    https://developer.apple.com/library/archive/referencelibrary/GettingStarted/DevelopiOSAppsSwift/WorkWithViewControllers.html

提交回复
热议问题