[英]How do I segue from a UINavigationController to a UIViewController
I have an app where this happens: 我有一个发生这种情况的应用程序:
First you look at UIViewController which lets you run a timer (for a running sprint across a Soccer field). 首先,您看一下UIViewController,它使您可以运行计时器(用于“足球”场上正在运行的sprint)。
So you finish your time, you see the result, and then you can do a few other things. 这样您就可以完成时间,看到结果,然后可以做其他一些事情。 One is that you can look at a list of your previous scores so I segue to a UINavigationController to show those (because if you choose one score, you can drill down and get more information about that sprint).
一种是您可以查看以前得分的列表,因此我可以选择UINavigationController来显示这些得分(因为如果选择一个得分,则可以向下钻取并获得有关该冲刺的更多信息)。
So I go on Storyboard, I add a button to UIViewController and when user touches it, they segue to the UINavigationController, do their business, and then they want to go back to the score. 因此,我继续使用Storyboard,在UIViewController中添加一个按钮,当用户触摸它时,他们会选择UINavigationController,开展业务,然后他们想回到比分。
But the first screen of UINavigationController doesn't have BACK button (because scene that presented it is not UINavigationController I think) and I can't make one appear in Storyboard. 但是UINavigationController的第一个屏幕没有BACK按钮(因为呈现的场景不是UINavigationController),因此无法在Storyboard中显示。 But I don't think that the first screen should be a navigation controller.
但是我不认为第一个屏幕应该是导航控制器。
Sorry if this is too simple, I just am missing how to make a back button show up on the first look of UINavigationController or if there is some other thing I am missing that is better way to do this all. 抱歉,如果这太简单了,我只是在UINavigationController的第一个外观上丢失了如何使后退按钮显示的方法,或者如果我缺少其他一些东西,那就是更好的方法。
Would like to do all this in storyboard if possible, just seems more future-proofs. 如果可能的话,希望在情节提要中执行所有这些操作,不过似乎更适合未来。
Embed your first view controller in a Navigation Controller. 将您的第一个视图控制器嵌入到导航控制器中。
The reason you can't go back to your first view is because you have your second view embedded in a Navigation Controller, so there is not a recognisable way back by using only storyboards; 无法返回第一个视图的原因是,因为第二个视图已嵌入导航控制器中,所以仅使用情节提要板是无法识别的。 there is no further navigational way back to it as you have gone:
您已经走了,没有其他导航方法可以回去了:
VC1 --> Nav Controller --> VC2 --> etc. VC1->导航控制器-> VC2->等等
Your navigation controller has no knowledge of VC1 so it needs to look like this: 您的导航控制器不了解VC1,因此需要如下所示:
Nav Controller --> VC1 --> VC2 --> etc. 导航控制器-> VC1-> VC2->等等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.