NeverwinterMoon
NeverwinterMoon

Reputation: 2451

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.

I am using Storyboard segues and the design I have in mind is the following:

[Navigation Controller] - nested -> [Controller 1] - present modally over context -> [Controller 2] - pushed -> [Controller 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.

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...

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.

Upvotes: 1

Views: 428

Answers (1)

NeverwinterMoon
NeverwinterMoon

Reputation: 2451

Aha, it seems that using UIViewController#isBeingDismissed provides the desired effect. 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.

Upvotes: 1

Related Questions