1

I have made on application using Xcode 4.5. and also use UIStoryboard in this application.

In this app, I push from one ViewController to second ViewController and then push from second ViewController to third ViewController.

Now, How I can Pop (back) directly from third ViewController to first ViewController.

Is it possible or not ? If possible, then How?

4

3 回答 3

1

这是可能的,只需使用这个..

  [self.navigationController popToViewController: [self.navigationController.viewControllers objectAtIndex:0] animated:YES];

您可以使用要弹出的任何控制器的值更改 objectAtIndex 的值

于 2012-12-06T09:46:34.283 回答
0

使用这个方法

popToRootViewControllerAnimated:

苹果文档

弹出堆栈上除根视图控制器之外的所有视图控制器并更新显示。

  • (NSArray *)popToRootViewControllerAnimated:(BOOL)动画

参数动画:将此值设置为 YES 以动画过渡。如果您在显示其视图之前设置导航控制器,则传递 NO。

返回值:从堆栈中弹出的视图控制器数组。

使用示例

 [self.navigationController popToRootViewControllerAnimated:YES];
于 2012-12-06T10:03:11.403 回答
0

您可以使用popToViewController并使用以下代码检查视图控制器是否在堆栈中。

for (UIViewController *aViewController in self.navigationController viewControllers)
{
    if ([aViewController isKindOfClass:[firstViewController class]])
                        {
                            firstViewController *FVC = (firstViewController*)aViewController;
                          [self.navigationController popToViewController:FVC animated:YES];
                        }
                    }

希望这可以帮助。

于 2018-01-11T05:42:59.020 回答