[英]Navigation Controller's Root View Controller
I have my viewControllers like this: 我有这样的viewControllers:
startViewController ------> menuViewController
\
\ ------> ImportantViewController
From startMenu
I pushed menuView
then I pushed again importantView
, on that I have made importantView
as my rootViewcontroller for it to become my parent view like as below: 从
startMenu
我推menuView
然后我又推importantView
,对我做了importantView
作为我的RootViewController的为它变成像下面我父母的看法:
UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController: vc];
[self presentModalViewController: navControl animated: YES];
From that I pushed view after importantView
via: 从那开始,我通过以下方法将
importantView
视图推入视图:
[self.navigationController pushViewController:vc animated:YES];
Now my prob is like this: 现在我的概率是这样的:
ImportantVIew
as my rootView
pushed to menuView
pushed to ViewA
then pushed to View B then option whether to return to menuView
or return to ViewA
. ImportantVIew
当我的rootView
推到menuView
推到ViewA
然后推到View B时,可以选择返回menuView
还是返回ViewA
。
My question is: I want to make my ViewB
as a rootView, then when I go to ImportantView
it will then return it to as rootView
. 我的问题是:我想将
ViewB
设为rootView,然后当我转至ImportantView
,它将随后以rootView
返回。 Is it possible to have 2 rootView? 是否可以有2个rootView? Or I need to just replace each other?
还是我需要互相替换?
Help would be much appreciated. 帮助将不胜感激。 Thanks.
谢谢。
What is the reason for changing the root view controller all the time? 始终更改根视图控制器的原因是什么?
With viewA and viewB calling in circle you would build up an endless stack of view controllers. 通过循环调用viewA和viewB,您将建立起无休止的视图控制器堆栈。 That is probably not what you want to do.
那可能不是您想要的。
Take a step back and re-think what you are trying to achive. 退后一步,重新考虑要达到的目标。 Do you just want to change between viewA and viewB?
您是否只想在viewA和viewB之间切换? In that case you sould go for a different architecture/pattern than the usual pushViewController thing.
在这种情况下,您会选择与通常的pushViewController不同的体系结构/模式。 Read a bit about removeFromParentViewController or transitionFromViewController:toViewController:.
阅读有关removeFromParentViewController或transitionFromViewController:toViewController:的内容。 Or get familiar with manipulating the chain of view controllers yourself.
或者自己熟悉如何操纵视图控制器链。 Those things might help achieving the user experience that you want to create without building up an endless stack of view controllers.
这些东西可能有助于实现您想要创建的用户体验,而无需建立无休止的视图控制器堆栈。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.