【问题标题】:Displaying different content view in the same uiviewcontroller by uitableview indexpath row通过uitableview indexpath行在同一个uiviewcontroller中显示不同的内容视图
【发布时间】:2012-03-26 03:25:29
【问题描述】:

我想在同一个 UIViewController 中显示不同的 UIImageView 取决于在 UITableView 中选择了哪个 indexpath 行。我有一个不明智的方法,它为不同的 UIImageView 创建了很多 UIViewController,但我不想这样做。有没有更聪明的方法可以实现这一点。非常感谢您的帮助。

【问题讨论】:

    标签: objective-c ios uitableview


    【解决方案1】:

    首先将UIImageView 添加到UIViewController 的视图中。

    创建一个NSMutableArray来存储UIImageViews,并在- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        imageView = [imageViewArray objectAtIndex:indexPath.row];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-26
      • 1970-01-01
      • 2016-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多