如何判断UIViewController的视图是否可见?

时间:2016-04-08 08:56:56

标签: ios

我有一个tabBar个应用,有很多views。有没有办法知道UIViewController中当前是否可以看到特定的UIViewController? (寻找property

1 个答案:

答案 0 :(得分:0)

var onScreen: Bool = false

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated: animated)
    onScreen = true
}

override func viewWillDisappear(animated: Bool) {
    super.viewWillDisappear(animated: animated)
    onScreen = false
}

然后您就可以访问viewControllerInstance.onScreen媒体资源。