【问题标题】:iOS - How to not present model view if it is presenting?iOS - 如果正在呈现模型视图,如何不呈现?
【发布时间】:2016-08-15 16:54:56
【问题描述】:

我有一个浮动按钮来呈现模型视图。我在 AppDelegate 中调用 presentViewController

UIApplication.sharedApplication().keyWindow?.rootViewController!.getTopViewController().presentViewController(myViewController, animated: false, completion: nil)

当 myViewController 呈现时,我再次单击浮动按钮,我的应用程序将再次调用 myViewController。那么呈现了怎么不呈现呢?

【问题讨论】:

    标签: ios swift appdelegate presentviewcontroller


    【解决方案1】:

    你可以做的是在你的按钮上添加一个检查来检查当前控制器是否正在呈现可以像这样完成的东西

    let controller = UIApplication.sharedApplication().keyWindow?.rootViewController!.getTopViewController()
    
    if controller.presentedViewController == nil {
           controller.presentViewController(myViewController, animated: false, completion: nil)
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-24
      • 1970-01-01
      • 2011-10-17
      • 1970-01-01
      相关资源
      最近更新 更多