I\'ve read the other posts on segues but none solve my question.
Simply put, my ViewControllers are ordered, like a book. I want backward transitions (
You can use of the predeclared type of transition in transitionWithView method
UIView.transitionWithView(self.window!, duration: 0.5, options:.TransitionFlipFromLeft, animations: { () -> Void in
self.window!.rootViewController = mainVC
}, completion:nil)
I guess .TransitionFlipFromLeft is the desired one
To complete the task, drag a new view controller to your storyboard and name it with some id. This is going to be the destination of the transition.
then instantiate this view controller from code
let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil)
let mainVC = storyboard.instantiateViewControllerWithIdentifier("someViewController") as! UIViewController
You can do this either inside the IBAction or for example in ViewDidLoad but probably IBAction will be the better choice. Pay attention to type the correct identifiers for both storyboard and view controller. Also, you have to declare your appDelegate instance. Here is the implemented IBAction
@IBAction func push(sender: UIButton) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let mainVC = storyboard.instantiateViewControllerWithIdentifier("secondVC") as! UIViewController
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
UIView.transitionWithView(appDelegate.window!, duration: 0.5, options: .TransitionFlipFromLeft , animations: { () -> Void in
appDelegate.window!.rootViewController = mainVC
}, completion:nil)
}
If this is not what you have expected, probably you might want to make a custom animation. This article is really helpful : http://mathewsanders.com/animated-transitions-in-swift/