Lets say I have 3 UIViewController
's - A, B and C. The transitions between A<->B and B<->C are done with different animated transitioning in both ways - forward and backward (unwind segue animation) subclassing UIViewControllerTransitioningDelegate
and UIViewControllerAnimatedTransitioning
. The transitions with just one step forward or backward work perfectly, but when I try to unwind more than one step back from C->A (like home button) - B is shown without animation and then B->A custom animation is played, which is weird looking. viewWillApper
is called for all middle view controllers on the chain (in my example B). It is almost like unwind from C->A is done this way - C->B->A instead of C->A (with one note - that only B->A animation is played, C->B animation is not played). What I want is just C->A (not B->A) animation, without showing any of other middle view controllers or calling their viewWillAppear
methods. I want to be able to set custom unwind segue animation for C->A. How can I do that?
NOTE 1: I don't embed my controllers in UINavigationController and I preffer not to, because as far as I know (correct me if I'm wrong) it is not very flexible or at least scalable for different custom animations between different steps. Neither way I prefer not to use it.
NOTE 2: I've tried to override
override func segueForUnwindingToViewController(toViewController: UIViewController, fromViewController: UIViewController, identifier: String?) -> UIStoryboardSegue
in A and return custom segue (UIStoryboardSegue
derived class) for the unwinding from C->A. The method was called, but the animation is starting and in the middle of it switch to B->A animated transition delegate animation (which I have set for transitioning between B->A). So this is not working also.
What I'm doing wrong? I'm pretty sure that Apple developers have this figured it out and made some sort of API or something like that. There is nothing in the Apple documentation about how to unwind few steps back with custom animation.
And one last thing unwind segue few steps back is working perfectly, just the custom animation is not or at least I can't make it work.
Any help will be highly appreciated.
I understand that in your question you clearly stated that you do not want to use UINavigationController
, and I understand this. So need to accept this answer.
But I would still promote using the UINavigationController
in this scenario, as it offer a lot of help tracking navigation, and is actually very flexible if extended, and even offers custom transitions via UINavigationControllerDelegate
and UIViewControllerAnimatedTransitioning
.
When it comes to navigating you can manually manipulate the navigation stack, using .pushToViewController()
and .popViewController()
or directly manipulating the list of controllers in .viewControllers
or popToRootController()
.
I have used UIKit
and UINavigationController
in a game that needed quite heavy transitions, and in my opinion it could take a lot of customization and still offer a great deal of help with navigation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With