Which method is called when back button clicked in navigation controller?

前端 未结 2 1599
太阳男子
太阳男子 2021-01-11 16:46

I want to save DB when the back button clicked in navigation controller.

so I would insert code in method.

What method is called when back button clicked in

2条回答
  •  独厮守ぢ
    2021-01-11 17:32

    To do what you asked, look at the UINavigationControllerDelegate protocol, namely the method:

    - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated 
    

    when the viewController argument is no longer your view controller then you should save.

    However, doing so on viewWillDisappear: might be a better (and much simpler) idea.

提交回复
热议问题