我使用UINavigation控制器,并有一个问题。是否有办法从第三视图切换到第一视图? 创建新对象FirstView *controller; [self.navigationcontroller pushViewController:controller animated:YES];
的方法不适合我(将转移的数据从父项丢失到第一个视图)。UINavigationController导航
回答
试试这个。它会工作。
您可以获取阵列中的所有视图控制器并弹出到特定视图控制器 。此代码将弹出到您的FirstView控制器。
NSArray *array = [self.navigationController viewControllers];
[self.navigationController popToViewController:[array objectAtIndex:1] animated:YES];
您可以使用:
[[self navigationController] popViewControllerAnimated:YES];
回去一个视图控制器;或:
[self.navigationController popToRootViewControllerAnimated:YES];
回到层次结构中第一个视图控制器。
'[自我navigationController] popViewControllerAnimated:YES];'将返回我'二View'和'[self.navigationController popToRootViewControllerAnimated:YES];'将返回'父View' .. – RomanHouse 2012-08-09 08:05:12
假设你知道你的视图控制器返回并存储在returnToViewController
:
[self.navigationController popToViewController:retunToViewContoller animated:YES];
再次同样,要做到这一点,我将需要创建'FirstView * returnToViewController',但在这种情况下,我失去了我的数据在***第一视图*** – RomanHouse 2012-08-09 08:14:44
@RomanHouse,不,你不会。您的FirstView控制器已经在导航堆栈上。你不应该再创建它。导航控制器将它们保存在一个数组中,并且只能导航结构。 – 2012-08-09 08:24:51
为什么要丢失任何数据?如果你这样做,那么你已经犯了任何其他与导航控制器的推送和弹出机制无关的错误。 – 2012-08-09 11:49:22
- 1. 导航栏UINavigationController太高
- 2. 的UINavigationController没有导航栏
- 3. uinavigationcontroller导航栏始终隐藏
- 4. UI导航大小问题与UINavigationController
- 5. UINavigationController导航栏没有正确定位
- 6. 阻止UINavigationController的导航栏动画?
- 7. 的UINavigationController的的导航栏dissappears
- 8. 没有UINavigationController的导航式行为
- 9. 指定自定义导航栏的UINavigationController
- 10. 带有静态导航栏的UINavigationController
- 11. UINavigationController上方的品牌栏导航栏
- 12. 导航背部,向前一个UINavigationController导致崩溃
- 13. 用于无限导航的UINavigationController(嵌套文件夹)
- 14. UINavigationController&“不支持导航控制器”异常?
- 15. 在一个UINavigationController的在每个导航项目设置按钮
- 16. 的UINavigationController的导航栏不会收缩时在横向模式
- 17. UITabBarController中的UINavigationController,设置导航控制器标题
- 18. 使用UINavigationController导航到另一个视图
- 19. Swift 3 - 添加导航项到UINavigationController子类
- 20. 翻转由UINavigationController管理的UIViewController隐藏导航栏
- 21. 如何使UINavigationController的导航栏显示在底部?
- 22. UITabBarController的'More'导航控制器在UINavigationController下消失
- 23. 在iOS中加载不同的UINavigationController:导航流不工作
- 24. 通过iPad上的UINavigationController ViewControllers进行导航
- 25. 只有一半导航栏正在显示UINavigationController
- 26. 基于导航的应用程序如何访问UINavigationController类?
- 27. UINavigationController中的UITableView导致EXC_BAD_ACCESS
- 28. Drupal 8导航menutrail导航
- 29. (Sitecore)与子导航导航
- 30. 使用自定义图像作为UINavigationController的导航栏的背景
它的工作原理!非常感谢! – RomanHouse 2012-08-09 08:23:57
这不会让你跳到第一个viewController ...第一个viewController是位于索引0处的'rootViewController'。 – 2012-08-09 08:28:29
@ Paul.s ParentView将位于索引0,FirstView位于索引1,SecondView位于索引2。 – iOSDev 2012-08-09 08:42:59