simonmaddox
simonmaddox

Reputation: 790

Unwinding a UIStoryboardSegue subclass in a UINavigationController

I'm trying to unwind a UIStoryboardSegue subclass. If the main window's rootViewController is a UIViewController subclass, everything works great.

However, if it's a UINavigationController subclass my segue is never triggered on unwind.

I've created a sample app to demonstrate this, and put it on Github: https://github.com/simonmaddox/CustomUnwindSegue

Upvotes: 0

Views: 1605

Answers (2)

simonmaddox
simonmaddox

Reputation: 790

After using a DTS request on this, Apple suggested the following:

The short answer is that when a UINavigationController is present, SMXViewController is not actually the parent of the presented SMXSecondViewController. As a result, it only has limited involvement in the unwinding process.

...

A way around this implementation detail is to use your own UINavigationController subclass. You can then override -segueForUnwindingToViewController:fromViewController:identifier: to implement your own logic or forward the message to the UINavigationController parent class if it's for an unwind segue you are not interested in.

The full solution also exists on the DTS_Response branch: https://github.com/simonmaddox/CustomUnwindSegue/tree/DTS_Response

Upvotes: 4

Rushi
Rushi

Reputation: 4500

Here is the complete example with explanation for you.

Upvotes: 0

Related Questions