I want to show an alert with Confirmation when user clicks on back button. This is how I'm trying to add action.
self.navigationItem.hidesBackButton = true
let newBackButton = UIBarButtonItem(title: "<", style: UIBarButtonItemStyle.plain, target: self, action: #selector(ViewController.save(sender:)))
self.navigationItem.leftBarButtonItem = newBackButton
This is working fine but I want the default back button image in it and not the custom title. How to do that ?
I tried following code as well :
self.navigationItem.backBarButtonItem?.action = #selector(ViewController.save(sender:))
...but the action is not performed, too.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…