【发布时间】:2012-03-26 03:25:29
【问题描述】:
我想在同一个 UIViewController 中显示不同的 UIImageView 取决于在 UITableView 中选择了哪个 indexpath 行。我有一个不明智的方法,它为不同的 UIImageView 创建了很多 UIViewController,但我不想这样做。有没有更聪明的方法可以实现这一点。非常感谢您的帮助。
【问题讨论】:
标签: objective-c ios uitableview
我想在同一个 UIViewController 中显示不同的 UIImageView 取决于在 UITableView 中选择了哪个 indexpath 行。我有一个不明智的方法,它为不同的 UIImageView 创建了很多 UIViewController,但我不想这样做。有没有更聪明的方法可以实现这一点。非常感谢您的帮助。
【问题讨论】:
标签: objective-c ios uitableview
首先将UIImageView 添加到UIViewController 的视图中。
创建一个NSMutableArray来存储UIImageViews,并在- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath中
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
imageView = [imageViewArray objectAtIndex:indexPath.row];
}
【讨论】: