0

ルートビューコントローラーと子ビューコントローラーを備えたナビゲーションアプリがあります。子-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

4

1 に答える 1

0

画面に戻るボタンを配置しないのはなぜですか。「質問」画面と想定した画面を表示したいのですが、「backToMenu」メソッドでは次のように使用できます。

[self.navigationController popToRootViewControllerAnimated:YES];
于 2011-05-12T01:04:06.793 に答える