繁体   English   中英

如何在 Swift 5 中关闭第一个弹出窗口并显示第二个弹出窗口?

[英]How to dismiss first popover and show second popver in Swift 5?

我有3个屏幕。 在第一个屏幕上,我有一个单击按钮,我正在显示一个弹出窗口。 在那个弹出窗口中我有一个按钮,在那个按钮上单击我想打开另一个弹出窗口,但第一个弹出窗口应该被关闭?

有没有办法做到这一点?

我正在使用这种方式来显示弹出视图控制器

@IBAction func btnManualEntry(_ sender: Any) {

        if let vc = self.storyboard?.instantiateViewController(withIdentifier:"SummaryManualEditVC") {
            vc.modalTransitionStyle   = .crossDissolve;
            vc.modalPresentationStyle = .overCurrentContext
            self.present(vc, animated: true, completion: nil)

        }
    }

只需引用presentingViewController ,当您关闭第一个弹出框时,在关闭后打开另一个。

@IBAction func btnManualEntry(_ sender: Any) {

    if let presentingVC = self.presentingViewController {
        self.dismiss(animated: true) {
            if let vc = self.storyboard?.instantiateViewController(withIdentifier:"SummaryManualEditVC") {
                vc.modalTransitionStyle   = .crossDissolve;
                vc.modalPresentationStyle = .overCurrentContext
                presentingVC.present(vc, animated: true, completion: nil)

            }
        }
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM