如何让UITableView的每一行将用户引导到新页面?

时间:2011-07-29 15:21:21

标签: iphone ios cocoa-touch uitableview

  

可能重复:
  Change view when tableview cell is pressed?

我有一个带有多行的UITableView,我想拥有它,以便点击每一行会带你到另一个视图。我怎么能这样做?

2 个答案:

答案 0 :(得分:1)

如果您将用户ID存储在与TableView数据相同的数组中,则可以使用indexPath访问此信息并将其传递给另一个控件,如UIViewController。例如。

NSDictionary *selectedUser = [MyTableViewDataArray objectAtIndex:indexPath.row];
MyUserViewController *userVController = [[MyUserViewController alloc] initWithUser:selectedUser];

然后你可以把这个viewcontroller推到堆栈上

[self.navigationController pushViewController:userVController animated:YES];
[userViewController release];

显然这是一个伪示例,但可以帮助你。

答案 1 :(得分:0)

从基于导航的应用程序模板创建一个新项目,XCode将为您生成示例代码。