ios - 如何在 self.dismiss block 中推送 UIViewController?

标签 ios swift uiviewcontroller swift3 dismiss

有 HomeViewController 作为主 viewController 和 LeftMenuViewController 在当前上下文中以模态方式呈现。现在在 LeftMenuViewController 中有打开 ProfileViewController 的选项,但我不想在 LeftMenuViewController 上显示 ProfileViewController,所以使用了这段代码,但由于某些未知原因它不起作用,LeftViewController 被关闭但 ProfileViewController 没有被推到前面。

@IBAction func editAction(_ sender: Any) {

        let homeVC:HomeViewController = self.presentingViewController!.childViewControllers[0] as! HomeViewController

        self.dismiss(animated: false) {
            DispatchQueue.global().async {
                let infoVC:ProfileViewController = self.storyboard?.instantiateViewController(withIdentifier: "ProfileViewController") as! ProfileViewController
                homeVC.navigationController?.pushViewController(infoVC, animated: true)
            }

        }

    }

任何建议都会很有帮助

最佳答案

改变

DispatchQueue.global() 

DispatchQueue.main

UI operations should be put in main queue

关于ios - 如何在 self.dismiss block 中推送 UIViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42750464/

相关文章:

ipad - 了解(符号化)iOS崩溃日志

ios - 在 NEON float32x4_t 中总结 3 条车道

ios - APNS 证书是否与 App Store 应用程序证书相同?

ios - 奇怪的按钮动画

ios - 在 View Controller 之间移动时保存文本字段中的内容

swift - 使用 UIViewController 不隐藏选项卡栏

ios - 是否可以使用 iOS 上的应用程序修改 CalDAV/CardDav 帐户?

swift - 多个协议(protocol)扩展中的模糊函数?

ios - GRDB swift 中的 DatabaseConnecton 问题

objective-c - 获取最顶层的 UIViewController