2017-03-12 23 views
0

HomeViewController作爲主視圖控制器和LeftMenuViewController以模態方式呈現在當前上下文中。現在在LeftMenuViewController中有打開ProfileViewController的選項,但我不想在LeftMenuViewController上顯示ProfileViewController,所以使用了這段代碼,但由於某種未知的原因,它不工作,LeftViewController被解僱但ProfileViewController未被推到前面。如何在self.dismiss塊中推UIViewController?

@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) 
      } 

     } 

    } 

任何建議將是非常有益的

+0

你能描述一下哪些方法無效嗎? 'ProfileViewController'不顯示或者'LeftMenuViewController'不隱藏 –

+0

LeftViewController被解除,但ProfileViewController不被推到前面。 –

+0

你是否嘗試調用'present'函數 –

回答

1

變化

DispatchQueue.global() 

DispatchQueue.main 

UI操作應在主隊列放在

+0

由於您已經在主隊列中,因此不需要整個調度。 – Sulthan

相關問題