简体   繁体   English

在UINavigationController中的UIViewController之间切换

[英]Switching between UIViewControllers within UINavigationController

So I'm stuck with a little problem that seems simple but is giving me fits. 因此,我遇到了一个看似简单但仍很适合我的小问题。

Basically, I've got this kind of thing set up: 基本上,我已经建立了这种东西:

(1)-->(2)-->(3) (1)->(2)->(3)

I drill down into a table, and once I'm at (3), I'd like to be able to swipe between two different views, while keeping the hierarchy intact. 我向下钻取一个表,一旦进入(3),我希望能够在两个不同的视图之间滑动,同时保持层次结构完整。 Like this: 像这样:

(1)-->(2)-->(3a)/(3b) where 3a and 3b are able to be swiped back and forth. (1)->(2)->(3a)/(3b),其中3a和3b可以前后滑动。 I also want to keep the back arrow for (2) on both views so that a user can go back. 我还想在两个视图上都保留(2)的后退箭头,以便用户可以返回。

The problem I'm having is that 3a and 3b will need to do separate calls for JSON data, so it's more than just loading two images. 我遇到的问题是3a和3b将需要对JSON数据进行单独的调用,因此它不仅仅是加载两个图像。 I really need to load each entirely... 我真的需要全部加载...

Any idea where to start? 知道从哪里开始吗? I'm experienced, but this just seems totally confusing. 我有经验,但这似乎完全令人困惑。 And I'm N2Deep to use storyboards now. 我现在要使用N2Deep情节提要。 Many thanks for any help! 非常感谢您的帮助!

The usual way I'd push a new view is like what I've done below. 我推送新视图的通常方式类似于下面的操作。 This obviously doesn't work in this case... 在这种情况下,这显然不起作用...

if (!self.objTomorrowDetailViewController) { self.objTomorrowDetailViewController = [[TomorrowDetailViewController alloc] initWithNibName:@"TomorrowDetailViewController" bundle:nil]; } 
[self.navigationController pushViewController:self.objTomorrowDetailViewController animated:YES];

Use navigationController.viewControllers to get the current view stack, create a new one based on it (either via a mutable, or the new syntax @[oldVCs[0],oldVCs[1],newVC] ). 使用navigationController.viewControllers来获取当前视图堆栈,并基于该视图堆栈创建一个新视图堆栈(通过可变的或新的语法@[oldVCs[0],oldVCs[1],newVC] )。 Set that to be the new stack with [navigationController setViewControllers:newVCArray animated:YES] . 使用[navigationController setViewControllers:newVCArray animated:YES]将其设置为新堆栈。

I think the best way to do this is with a custom container controller as your controller 3. When you do your push from 2, it would load the custom container which you could have set to display one of two (or more if you wanted) of its child controllers. 我认为最好的方法是使用自定义容器控制器作为控制器3。从2进行推送时,它将加载自定义容器,您可以将其设置为显示两个(如果需要的话)之一其子控制器。 The swipe gesture would switch between the container controller's 2 child controllers, and you could still get back to 2 from either view. 滑动手势将在容器控制器的2个子控制器之间切换,并且您仍然可以从任一视图回到2。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在uiviewcontrollers之间切换时出现short的多个实例 - multiple instances of a short when switching between uiviewcontrollers 在多个UIViewController之间切换时如何在UIImageView中保留图像 - How to keep an image in a UIImageView when switching between multiple UIViewControllers UINavigationController并在一个级别内切换下一个上一个项目 - UINavigationController and switching next-prev item within one level 推送到UINavigationController时UIViewControllers出现问题-iOS 7.1 - Trouble with UIViewControllers when pushing to UINavigationController - iOS 7.1 UINavigationController 如何跟踪多个 UIViewController? - How does UINavigationController keep track of multiple UIViewControllers? 在UIVIewControllers之间隐藏按钮 - Hiding a button between UIVIewControllers 在UIViewController中嵌入UIViewControllers数组 - Embedding an array of UIViewControllers within a UIViewController 使用UINavigationController链接UIViewControllers推和弹出动画,关闭/显示模式视图? - Chain UIViewControllers push and pop animation with UINavigationController dismiss / present modal view? 使用UINavigationController循环UIViewControllers时,内存使用增加的问题 - Issue with increase memory usage when looping UIViewControllers using UINavigationController 使用UISegmentedControl在UIViewController之间切换 - Switch between UIViewControllers using UISegmentedControl
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM