Skip to content

Instantly share code, notes, and snippets.

@maheshgiri
Last active November 17, 2016 09:56
Show Gist options
  • Save maheshgiri/76e624ddd9e83d47b853c9f189767581 to your computer and use it in GitHub Desktop.
Save maheshgiri/76e624ddd9e83d47b853c9f189767581 to your computer and use it in GitHub Desktop.
Swift 3 Create Custom Segue
In swift3 create one segue -add identifier -add and set in segue(storyboard) custom storyboard class from cocoatouch file -In custom class override perform()
'override func perform() {
let sourceViewController = self.source
let destinationController = self.destination
let navigationController = sourceViewController.navigationController
// Pop to root view controller (not animated) before pushing
if self.identifier == "your identifier"{
navigationController?.popViewController(animated: false)
navigationController?.pushViewController(destinationController, animated: true)
}
}'
-You also have to override one method in your source viewcontroller
' override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
return false
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment