Iphone Tableview选择行

Iphone Tableview选择行,iphone,uitableview,uiimage,Iphone,Uitableview,Uiimage,我有一个tableview,其中包含单元格中的图像 如果我触摸表格任何一行中的图像,它应该重定向到下一页,并在下一页显示相应的图像 请帮助我了解如何执行此操作?使用didSelectRowAtIndexPath委托: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 通过知道使用[indexPath行]选择了哪个UITableviewCell,您将获得所需的内容

我有一个tableview,其中包含单元格中的图像

如果我触摸表格任何一行中的图像,它应该重定向到下一页,并在下一页显示相应的图像

请帮助我了解如何执行此操作?

使用didSelectRowAtIndexPath委托:

 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
通过知道使用[indexPath行]选择了哪个UITableviewCell,您将获得所需的内容,让我们假设您将UIImages存储在数组MyImagesArray中

这是对第3条评论的另一个回答:

在UIViewController中声明一个变量,该变量将显示图像并传递所选图像,或者您甚至可以发送UIImage的名称:

在ImageViewer中,按图像名称加载图像,例如:

 UIImage *image = [UIImage imageNamed:self.sSelectedImageName];

@Ahamad你能详细解释一下吗?我有5行5个图像,如果我选择第一行,它将重新进入下一页并显示该图像。@Nipin pn:cool,你正在使用UINavigationController,你想推出新的控制器吗?或者您想添加新的UIView?我正在使用UINavigationController,我想将其推送到下一个视图并显示相应的图像,我知道如何从一个视图推送到另一个视图,但不知道如何传递image@Ahamad我正在使用UINavigationController,我想将它推到下一个视图并显示相应的图像,,我知道如何从一个视图推到另一个视图,但不知道如何传递图像
 ImageViewer* oImageViewer = [[ImageVieweralloc] initWithNibName:@"ImageViewer" bundle:nil];

 // Assume MyImagesArray contains the images names.
 oImageViewer.sSelectedImageName = [MyImagesArray objectAtIndex:[indexPath row]];

 [self.navigationController pushViewController:oImageViewer animated:YES];
 UIImage *image = [UIImage imageNamed:self.sSelectedImageName];