Skip to content

Instantly share code, notes, and snippets.

@dethell
Last active August 29, 2015 14:04
Show Gist options
  • Save dethell/bd693a3ec2c10717fbf7 to your computer and use it in GitHub Desktop.
Save dethell/bd693a3ec2c10717fbf7 to your computer and use it in GitHub Desktop.
Swift version of viewWillDisappear needed for custom storyboard back button behavior
override func viewWillDisappear(animated:Bool) {
if let currentViewControllers = self.navigationController.viewControllers as? [UIViewController] {
if let found = find(currentViewControllers, self) {
// Do nothing if the current controller is still in the stack. This means we're going forward, not back
}
else {
self.performSegueWithIdentifier("unwindToLogin", sender:self)
}
}
super.viewWillDisappear(animated)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment