Controlling changes in the navigation stack

白昼怎懂夜的黑 提交于 2019-12-25 01:32:59

问题


I want to be able to check for specific conditions when a user selects the "back" button from a navigation controller - then display an alert and stop the pop up the navigation stack from occurring.

I can get notified in the viewWillDissappear method that the pop is about to occur - but is there a mechanism to stop the pop from happening?


回答1:


You can try subclassing UINavigationController and then override the popViewController method to include your logic.

- (UIViewController *)popViewControllerAnimated:(BOOL)animated

[edit to include an example] http://www.hanspinckaers.com/custom-action-on-back-button-uinavigationcontroller

Cheers, Rog



来源:https://stackoverflow.com/questions/4230455/controlling-changes-in-the-navigation-stack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!