当thirdViewController在Swift中呈现时关闭secondViewController

问题描述:

我有树视图控制器。当secondViewController显示出来时,我尝试在这个时候呈现thirdViewController,我想关闭secondViewController,因为无论何时我想尝试在thirdViewController中关闭,我想查看firstViewController,看不到第二个。这里是我的代码,我已经尝试过当thirdViewController在Swift中呈现时关闭secondViewController

self.presentViewController(thirtVC, animated: true) {() -> Void in 

       dispatch_after(0, dispatch_get_main_queue(), {() -> Void in 
        self.navigationController?.dismissViewControllerAnimated(false, completion: {() -> Void in 

        }) 
       }) 

      } 

并且它不适用于这种情况。请问哪里会有问题。

+0

你确定你是不是介绍你'secondViewController',并推动它在'UINavigationController'? ? – Rajat

+0

是在thirdVC中没有UINavigationController。但firstViewController具有UINavigationController。 – ali

+0

我只是问你如何添加secondViewController? – Rajat

如果您呈现视图,那么你必须解散你的viewController,则提出了另一个的viewController这样,

self.dismissViewControllerAnimated(true, completion: {() -> Void in 
     self.presentViewController(thirtVC, animated: true) {() -> Void in 
    } 
} 
+0

它不是我想要的。如果我编写该代码,用户将在thirdViewController出现之前看到firstViewController。 – ali