Unfortunately, you can't intercept the back button in this way. The closest facsimile is to use your own UIBarButtonItem
set to the navigationItem.leftBarButtonItem
and set an action to display your alert etc. I had a graphic designer create button images that look like the standard back button.
As an aside, I needed to intercept the back button for a different reason. I urge you to reconsider this design choice. If you are presenting a view where users can make changes and you want them to have the choice to save or cancel IMHO it's better to use 'Save' and 'Cancel' buttons vs a back button with an alert. Alerts are generally annoying. Alternatively, make it clear that the changes your users are making are committed at the time they make them. Then the issue is moot.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…