如何快速查看是否有“已呈现”视图?

问题描述

  1. 我有TabsViewController,其中3个TabsUINavigationControllers发起。

    enter image description here

  2. 当我切换tabs#2和#3时,我想返回时在popUpViewController#1接收最新的tab

  3. 问题是如果您调用.overCurrentContext,当您从另一个tab返回时它将消失,但是其他viewControllers仍然显示正确地放在NavigationController堆栈上。

    // AGREEMENT
    @IBAction func btnpressed(_ sender: Any) {
    if let vc = storyboard?.instantiateViewController(withIdentifier: "AgreementVC") as? AgreementVC {
         vc.callBack = { (id: String,name: String,age: Int) in
            print(id,name,age)
    
            // change the state for parent view
            self.agree.setimage(UIImage(named: "CheckBoxTrue"),for: .normal)
            self.send.isHidden = false
        }
        vc.modalPresentationStyle = .overCurrentContext
        vc.modalTransitionStyle = .crossdissolve
        self.navigationController?.present(vc,animated: true)
    }
    }
    
  4. 我的想法是检查PresentedViewControllerdismiss AgreementVC()是否在内存中之前:

    override func viewDidAppear(_ animated: Bool) {
    
        if self.navigationController?.presentedViewController == AgreementVC(){
            print("+ the popUpView was here")
            self.navigationController?.dismiss(animated: false,completion: nil)
        } else { 
            print("- no popUpView")
        }
    }
    

当我切换不带popUp的选项卡时-是确定,但是如果我确实打开popUpVC,则会出现错误(该错误仍然存​​在,但是会从图形中消失用于用户屏幕):

警告:尝试提出上 呈现

如何正确检查显示的ViewController? 此问题适用于未从其他StackOverFlow主题获得答案的人。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...