【问题标题】:UITableView Question?UITableView 问题?
【发布时间】:2011-09-20 02:35:28
【问题描述】:

我有一个简单的UITableView 设置,但我希望每个项目都包含一个图像。因此,当您单击一个项目时,会转到一个图像。你觉得我会怎么做?我的列表(数组)中有大约 10 个项目将在 TableView 中。

【问题讨论】:

  • You mean u want to add an image to each row and when that particular row is selected, the corresponding image should open up ?

标签: objective-c xcode ios4 xcode4


【解决方案1】:

UITableViewDataSource Protocol 是必读的。正确实施协议后,使用 tableView:didSelectRowAtIndexPath 就是您的答案。根据您的实施要求,此答案可能略有不同,但协议仍然是解决方案。

【讨论】:

    【解决方案2】:

    你需要一个 UITableViewCell 子类。

    http://zcentric.com/2008/08/05/custom-uitableviewcell/

    这几乎可以满足您的需求。

    【讨论】:

    • 不需要自定义UITableViewCell。他可以使用包含图像和标题的标准单元格样式,或者在tableView:cellForRowAtIndexPath: 方法中将简单的 UIImageView 作为子视图添加到标准中。
    • 我的印象是他需要的不仅仅是默认值。唔。 :)
    【解决方案3】:

    如果您还没有这样做,请添加一个导航控制器来处理表格视图和图像之间的切换。

    然后覆盖tableview方法:didSelectRowAtIndexPath

    [self.navigationController pushViewController:theViewControllerContainingTheImage animated:YES];
    

    【讨论】:

      【解决方案4】:

      在 tableview 和 Array 中排列项目 之后在 UITableView 的 didselectrowAtIndexPath 委托中使用它 [myImageView setimage:[picArray objectAtIndex:indexpath.row]];

      【讨论】:

        猜你喜欢
        • 2021-11-30
        • 2011-02-03
        • 2012-05-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-04-01
        • 2011-11-20
        • 2011-08-13
        相关资源
        最近更新 更多