如何自动弹出到以前的viewController?

问题描述:

我连mainViewController和customTableViewController用“推” SEGUE。 mainViewController在prepareForSegue中将一个数据数组传递给customTableViewController。如果数组为空,customTableViewController会自动弹回到mainViewController。如何自动弹出到以前的viewController?

我的代码如下所示:



    //customTableViewController.m 
    - (void) viewDidload 
    { 
     if (self.array.count == 0) { 
      [self.navigationController popViewControllerAnimated: YES]; 
     } 
    } 

但我的一切是一个空白,黑色的观点,如果数组是空的,而不是mainViewController。

如果我手动调用popViewControllerAnimated(如按一个按钮),一切都只是工作如我所料。所以我该怎么做?

谢谢大家提前。

尝试使用您的代码-viewDidAppear:(BOOL)animated