我可以弹出特定ViewController吗? [英] Can i pop to Specific ViewController?

查看:98
本文介绍了我可以弹出特定ViewController吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用基于导航的应用程序。我将First ViewController推送到Second ViewController,从Second ViewController推送到Third ViewController。现在我想从Third ViewController弹出到First ViewController。我正在使用下面的代码执行此任务,但我的应用程序崩溃。

I am using navigation based application. I push First ViewController to Second ViewController and from Second ViewController to Third ViewController. Now I want to pop from Third ViewController to First ViewController.I am performing this task using the below code but my application crashed.

请任何机构给我一些正确的指导。我不能使用pop到rootViewController,因为它是不同的viewController。在此先感谢...

Please any body give me some proper guidelines. I can't use pop to rootViewController because it's different viewController. Thanks in advance...

在第三个ViewControler中我写了这个:

FirstViewCtr *x=[[FirstViewCtr alloc] initWithNibName:@"FirstViewCtr" bundle:nil];
[self.navigationController popToViewController:x animated:NO];


推荐答案

通过编写第一行,您将获得所有索引查看控制器和第二行您将到达目的地。

By Writing the First Line you get the Indexes of all View Controllers and from second Line You will reach up to your Destination.

NSArray *array = [self.navigationController viewControllers];

[self.navigationController popToViewController:[array objectAtIndex:2] animated:YES];

这篇关于我可以弹出特定ViewController吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆