0

UITableViewの任意の行が選択されたときに、完了ボタンをUINavigationBarに表示させたいのですが、このボタンでアクションを実行したいと思いますperformSegueWithIdentifier。それを実装する方法について何かアイデアはありますか?

4

2 に答える 2

1

tableView:didSelectRowAtIndexPath:メソッドに以下を追加します。

//add done button to navigation bar
UIBarButtonItem *doneBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(userPressedDone)];
self.navigationItem.rightBarButtonItem = doneBarButtonItem;

次に、ViewControllerのどこかに次のようなメソッドを設定します。

-(void)userPressedDone {
    //perform segue
    [self performSegueWithIdentifier:@"mySegue" sender:nil];
}
于 2012-05-08T18:27:21.873 に答える
0

あなたの-didSelectRowAtIndexPath:方法では、ViewControllerUIBarButtonItemのの右または左のバーボタン項目にを追加するnavigationItemと思います。

于 2012-05-08T18:20:14.023 に答える