以下の関数を使用して行を選択すると、選択した行のデータを取得します。
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
この選択されたデータを次のページに渡す方法。
2 番目のビューで変数を設定します。行が選択されると、
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
が呼び出されたら、選択したデータをこの関数の変数に設定します。
次に、2 番目のビューから変数を操作できます。これは、2 番目のビューをインスタンス化することを前提としています....
プロパティは、このように文字列、配列などを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];
}