ルートビューコントローラーと子ビューコントローラーを備えたナビゲーションアプリがあります。子-didSelectRowAtIndexPath
メソッドでは、次のようにターゲット/アクションを含む戻るボタンを追加します。戻るボタンを選択すると、(前の)子ビューではなくルートビューに戻ります。ただし、アクションメソッドが起動しない理由がわかりません。
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Question *newQuestion = [[Question alloc]
initWithNibName:@"Question"
bundle:nil];
newQuestion.testQuestion = self.testQuestion;
[self.navigationController dismissModalViewControllerAnimated:YES];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc]
initWithTitle:@"Quiz"
style:UIBarButtonItemStylePlain
target:self
action:@selector(backToMenu)];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];
[self.navigationController pushViewController:newQuestion
animated:YES];
[newQuestion release];
}
私のQuestionクラスの一番上に、backToMenuメソッドを含めます。
-
(void)backToMenu {
NSLog(@" backToMenu");
[self.navigationController popViewControllerAnimated:YES];
ただし、-backToMenu
解雇されることはありません。ディスプレイが表示されませんNSLog
。トリガー-viewWillAppear
されますが、戻るボタンが押されているか、テーブルの行が選択されているために、そこにいるかどうかを確認する方法がわかりません。おそらくあなたには明らかですが、私は困惑しています... thx