【问题标题】:How to tell if UIViewController's view is visible or not?如何判断 ViewController 视图是否可见?
【发布时间】:2016-07-29 11:23:27
【问题描述】:

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

【问题讨论】:

    标签: ios


    【解决方案1】:
    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 属性。

    【讨论】:

      猜你喜欢
      • 2011-02-16
      • 2014-05-03
      • 1970-01-01
      • 1970-01-01
      • 2015-12-29
      • 2010-10-18
      • 1970-01-01
      • 2010-09-12
      相关资源
      最近更新 更多