一旦小部件消失,哪些功能被调用?

时间:2016-10-31 11:11:48

标签: ios objective-c swift

什么是小部件生命周期?首先调用哪个函数?

1 个答案:

答案 0 :(得分:2)

viewDidLoad()在视图生命周期中只调用一次。

根据您的需要,使用:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    // do stuff you want to do before the view actually appears
} 

或:

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    // do stuff you want to do when the view appears
} 

有关UIView生命周期访问Apples Documentation

的详细信息