1

いくつかのセグメント化されたコントロール、テキスト フィールド、およびテーブル ビューを含むページがあります。ユーザーは、必要なものを書き込み/選択してから、すべての値を別のビューに渡すボタンをタップします (これらの値は検索の実行に使用されます)。これは、値を渡す関数の単純化されたバージョンです。

-(IBAction) doTheSearch {
    [self dismissViewControllerAnimated:YES completion:nil];  
    // initialize the view who will perform the search
    NewSearchController *nsc = [[NewSearchController alloc] init];
    // set values from one text field and one segmented control
    nsc.testString = textfield.text;    
    NSString *temp = [NSString stringWithFormat:@"%d",segmentedcontrol.selectedSegmentIndex];
    nsc.testCode = temp;
    [self.navigationController pushViewController:nsc animated:YES];
}

テキスト フィールドとセグメント化されたコントロールの値に対して行うのと同じ関数を使用して、テーブル ビューから選択されている行を取得することはできますか?

4

1 に答える 1

1
  NSIndexPath *path = [self.tableView indexPathForSelectedRow];


上記のコードから、indexPathを取得できます

path.row 

選択した正確な行を取得します。

于 2013-03-04T10:28:03.747 に答える