我是iPhone的新手,我有一个表格视图。使用以下函数选择行时,我获取所选行的数据。
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
如何将此所选数据传递到下一页。
在第二个视图中设置变量。选择该行时,这意味着
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
,将所选数据设置为此函数中的变量。
然后,您可以从第二个视图中操作变量。这是您实例化第二个视图的。
属性在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];
}