Created
October 13, 2020 17:30
-
-
Save foxicode/c93b67be4bf16e8cc5356f2b463308b3 to your computer and use it in GitHub Desktop.
Universal go-back function
This file contains hidden or 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
| import UIKit | |
| extension UIViewController { | |
| @IBAction func goBack() { | |
| if let nc = navigationController, | |
| nc.viewControllers.count >= 2 { | |
| nc.popViewController(animated: true) | |
| } else { | |
| dismiss(animated: true, completion: nil) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment