简体   繁体   English

使用Storyboard Segues将视图控制器从模态推送到模态父级使用的导航控制器

[英]Push view controller from modal into navigation controller used by parent of the modal using Storyboard segues

First of all, I did look around and found some similar questions, but none of the answers to those showed if it is possible to do using Storyboard segues and how. 首先,我确实环顾四周,发现了一些类似的问题,但是如果可以使用Storyboard segues及其方法,那么这些问题都没有答案。

I am using Storyboard segues and the design I have in mind is the following: 我正在使用Storyboard segues,因此我想到的设计如下:

[Navigation Controller] - nested -> [Controller 1] - present modally over context -> [Controller 2] - pushed -> [Controller 3] [导航控制器]-嵌套-> [控制器1]-在上下文中模态呈现-> [控制器2]-推入-> [控制器3]

I set up the above design and it works just fine visually, and I can move back and forth between all three controllers, but I expected Controller 3 to be nested in Navigation Controller , as it was pushed from Controller 2 , which in turn was presented modally from Controller 1 which was nested in Navigation Controller . 我设置了上面的设计,并且视觉效果很好,并且可以在所有三个控制器之间来回移动,但是我希望Controller 3嵌套在Navigation Controller ,因为它是从Controller 2推入的,而后者又被提出从嵌套在Navigation Controller Controller 1模态化。

I assumed that pushing Controller 3 from Controller 2 was actually pushing it to the existing Navigation Controller , as parent of the modal was nested in there... 我假设从Controller 2推送Controller 3实际上是将其推送到现有的Navigation Controller ,因为模态的父级嵌套在其中。

Oh, and my original problem was the following: I was trying to use UIViewController#isMovingFromParent from Controller 3 when unwinding back to Controller 2 and it always returned false. 哦,我的原始问题如下:当试图退回到Controller 2时,我尝试使用Controller 3 UIViewController#isMovingFromParent ,并且它始终返回false。

Aha, it seems that using UIViewController#isBeingDismissed provides the desired effect. UIViewController#isBeingDismissed ,看来使用UIViewController#isBeingDismissed可以达到预期的效果。 I knew that it worked from the modally presented controller, but it seems it also works for pushed controllers, that is if they were pushed from the modally presented view controllers. 我知道它可以从模态呈现的控制器中工作,但是似乎它也适用于推送控制器,也就是说,如果它们是从模态呈现的视图控制器中推送的。

I still have so much to learn. 我还有很多东西要学。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM