Stack Overflow:Setting action for back button in navigation controller
本文采用 Category 方法:UIViewController-BackButtonHandler
使用:
将下载的文件 UIViewController+BackButtonHandler 拖入工程
-
在需要处理的 ViewController 中重写方法:
- (BOOL)navigationShouldPopOnBackButton { if (needsShowConfirmation) { // Show confirmation alert // ... return NO; // Ignore 'Back' button this time } return YES; // Process 'Back' button click and Pop view controler }
顺便记录: 设置下一个页面的返回键文字
UIBarButtonItem *backbutton = [[UIBarButtonItem alloc]init];
backbutton.title = @"返回";
self.navigationItem.backBarButtonItem = backbutton;