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 }
順便記錄: 設(shè)置下一個頁面的返回鍵文字
UIBarButtonItem *backbutton = [[UIBarButtonItem alloc]init];
backbutton.title = @"返回";
self.navigationItem.backBarButtonItem = backbutton;