我發現,「檢測時,後退按鈕被按下」最好的辦法是重新定義viewWillDisappear
像這樣:
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
if (!isPushing) {
// Apply your changes here
}
}
布爾isPushing
將是一個自己定義的,你把它設置爲True只有在你自己推動另一個控制器的地方(如果你這樣做的話),你可以區分viewWillDisappear
,因爲你正在自己推新控制器,因爲後退按鈕被按下。
你常常使另一個控制器自己在一個表控制器像這樣:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Example of pushing a new controller onto the navigation stack yourself...
isPushing = YES; // You have to set that boolean here...
[self.navigationController pushViewController:myNewController animated:YES];
}
這正是我的選擇#1,但如果這是可能的,我不喜歡模擬本地外觀和感覺。 – SergGr 2009-12-15 20:51:13