If the answer provided by Xcoder does not do what you want check this one
https://stackoverflow.com/a/37230710/1152683
It consists in creating an custom button, but with the arrow. Check the answer for the whole code
The usage is pretty simple
weak var weakSelf = self
// Assign back button with back arrow and text (exactly like default back button)
navigationItem.leftBarButtonItems = CustomBackButton.createWithText("YourBackButtonTitle", color: UIColor.yourColor(), target: weakSelf, action: #selector(YourViewController.tappedBackButton))
// Assign back button with back arrow and image
navigationItem.leftBarButtonItems = CustomBackButton.createWithImage(UIImage(named: "yourImageName")!, color: UIColor.yourColor(), target: weakSelf, action: #selector(YourViewController.tappedBackButton))
func tappedBackButton() {
// Do your thing
}
EDIT:
Keeping the original button
Knowing that, for you this isn't working
override func viewWillDisappear(_ animated : Bool) {
super.viewWillDisappear(animated)
if self.isMovingFromParentViewController {
print("something")
}
}
I can only assume that when tapping the save button you're navigating to the previous screen there for you must add a flag inside that function and then add a condition to that function like so
override func viewWillDisappear(_ animated : Bool) {
super.viewWillDisappear(animated)
if self.isMovingFromParentViewController && !save {
// back pressed
}
}
being the save variable a Bool that becomes true when the save button is tapped