我有一个tabBar应用程序,其中有许多views。是否有办法知道UIViewController内部当前是否显示特定的UIViewController? (寻找property)

最佳答案

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属性。

关于ios - 如何判断UIViewController的 View 是否可见?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36495490/

10-13 04:29