2017-07-31 29 views
0

我有以下结构:如何解雇overCurrentContext模态viewController及其子项?

  • mainVC我提出一个模式的viewController,modalVC

    let modalVC: ModalVC = ModalVC() 
    modalVC.modalPresentationStyle = .overCurrentContext 
    modalVC.modalTransitionStyle = .coverVertical 
    self.present(modalVC, animated: false, completion: nil) 
    
  • modalVC我提出了另一个的viewController chatVC,但这次没有.overCurrentContext选项:

    let chatVC: ChatVC = ChatVC() 
    self.present(chatVC, animated: false, completion: nil) 
    

在这一点上,我有以下几点:

mainVC --present模态 - >modalVC --present - >chatVC

我要解雇chatVCmodalVC再次显示mainVC

我想:

self.presentingViewController?.presentingViewController?.dismiss(animated: false, completion: nil) 

没有成功。

任何想法?在此先感谢

+0

确保self.presentingViewController?.presentingViewController是mainVC。 – HMHero

回答

1

它有时可以帮助有点冗长......有助于了解正在发生的事情与您期望发生的事情。像这样试试吧:

if let myPresenter = self.presentingViewController { 

     if let hisPresenter = myPresenter.presentingViewController { 

      hisPresenter.dismiss(animated: false, completion: nil) 

     } 

    } 

如果那不“工作”,你至少可以在调试中逐步了解哪些是不正确的。

相关问题