Action to Navigation bar back button

前端 未结 6 1528
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-19 20:06

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
         


        
6条回答
  •  佛祖请我去吃肉
    2020-12-19 20:52

    I don't know what you try to achive, but isn't it a possible solution to do, what you want, whenever vieWillDisappear: got called? This is maybe a matching entrypoint without fiddeling around with the back-bar-button suggested in the other answers.

    Better Another option would be to implement the UINavigationControllerDelegate, set your controller as delegate and then implement your alert in navigationController(_:willShow:animated:).

    Take a look here for reference.

提交回复
热议问题