有 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/