-4

以下の関数を使用して行を選択すると、選択した行のデータを取得します。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

この選択されたデータを次のページに渡す方法。

4

2 に答える 2

1

2 番目のビューで変数を設定します。行が選択されると、

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

が呼び出されたら、選択したデータをこの関数の変数に設定します。

次に、2 番目のビューから変数を操作できます。これは、2 番目のビューをインスタンス化することを前提としています....

于 2012-11-09T06:07:58.063 に答える
0

プロパティは、このように文字列、配列などをyourNextViewController.hファイルに合成します。

@property(nonatomic, retain) NSMutableArray *nextViewArray;

そしてyourNextViewController.mファイルでは、次のように合成します。

@synthesize nextViewArray;

そして、次のように気絶します。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
      yourNextViewController *objNextView = [[yourNextViewController alloc]initWithNibName:@"yourNextViewController" bundle:nil];
      objNextView.nextViewArray = [[NSMutableArray alloc]init];
      objNextView.nextViewArray = [yourCurrentArray objectAtIndex:indexPath.row];
      [objNextView.nextViewArray retain];
      [self.navigationController pushViewController:objNextView animated:YES];
      [objNextView release];
}
于 2012-11-09T06:12:21.177 に答える