Last active
August 29, 2015 14:19
-
-
Save sgoodwin/2df91dc1974c49c01f8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ForwardSegue: UIStoryboardSegue { | |
override func perform() { | |
let source = self.sourceViewController as! UIViewController | |
let destination = self.destinationViewController as! UIViewController | |
let window = UIApplication.sharedApplication().keyWindow! | |
window.insertSubview(destination.view, aboveSubview: source.view) | |
destination.animateIn() | |
source.animateOut { | |
// To fix the issue with unbalanced viewwillappear/disappear calls | |
destination.viewWillDisappear(true) | |
destination.viewDidDisappear(true) | |
dispatch_async(dispatch_get_main_queue(), { () -> Void in | |
source.presentViewController(destination, animated: false, completion: nil) | |
}) | |
} | |
} | |
} | |
class BackSegue: UIStoryboardSegue { | |
override func perform() { | |
let source = self.sourceViewController as! UIViewController | |
let destination = self.destinationViewController as! UIViewController | |
let window = UIApplication.sharedApplication().keyWindow! | |
destination.dismissViewControllerAnimated(false, completion: { () -> Void in | |
window.insertSubview(source.view, aboveSubview: destination.view) | |
source.animateOut { | |
source.view.removeFromSuperview() | |
} | |
destination.animateIn() | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment