I'm developing a content rich app that has 60+ screens
I want to make animated segues between them without making storyboard arrows or connections,to semplify things, let's say I only have an app with 9 screens, A,B,C,D,E,F,G,H,I
if I use storyboards segues, then I will need to make a connection between each screen and the other back and forth... and end up with spaghetti/spider stuff, have a look at this screen for example, this is because almost any screen can lead to the other in the app i'm developing
so, what I need help with is the following,
1- How to make animated segues without having to use interface builder connections?
what I use is this
ram.vc = self.storyboard!.instantiateViewControllerWithIdentifier("MeBeforeSignUp") //MeBeforeSignUp
ram.vc.modalTransitionStyle = UIModalTransitionStyle.CrossDissolve
self.presentViewController(ram.vc, animated: true, completion: nil)
THE SEQUENCE : A->B->C->G->F->B->C->A->B->D->B->C
I move in the sequence from [A] to ... [C]
now I'm in [C], I have a back button that goes back to [B]
now I'm in [B], I have a back button that goes back to [D] ...
etc until I reach [A] without a back button because the stack is empty
Have a look at the
UIViewControllerAnimatedTransitioning protocol. It's a bit of a tough nut to crack, but once you do you will be able to create any animated transition you want without being bound by IB or its default animations.
Essentially, you will embed your initial view controller in a
UINavigationController as normal. Hooking up the
AnimatedTransitioning will allow you to intercept each Push and Pop in the navigation controller and dictate what animation they should use instead. This will give you the custom animations you seek, plus the normal navigation stack.
As for the back button, you would either need to show the navigation bar which would include it naturally, or add a button to your views that would pop the view controller from the stack.
------------- EDIT to provide point by point answers -------------
You should make use of the
UIViewControllerAnimatedTransitioning protocol I mentioned above. It's a big topic, but thankfully there are ample tutorials and explanations of how it works online. Confusing at first, but awesome once it settles in. Unfortunately not a cut and paste answer type situation.
If you embed your view controller A in a
UINavigationController, you get this behavior out of the box. If you don't want to see the bar at the top of the screen, you can hide it and programmatically call the
popViewController method when appropriate to go back one viewController in the stack.
Modally presented view controllers are not added to the navigation controller's stack, so I would avoid using
presentViewController or any modally presented transitions. In order to get the behavior you are after, you should instead push and pop your view controllers with the navigation controller rather than present. I do wish they gave us more default transitions, but developers are encouraged to create custom ones appropriate to their apps.
UIViewControllerAnimatedTranisitioning you can create pretty much any transition you want. You can really get creative and give your app a unique feel this way.
Same as the answer to 4. You can control every aspect of every animation in your transition. It's entirely custom.
UINavigationController's default behavior. You should be fine memory-wise as long as you don't leave a bunch of long running tasks on the view controllers alive in the stack. Unlikely you would be doing that anyway.