【问题标题】:Lazy loading issue in UITableViewUITableView 延迟加载问题
【发布时间】:2013-08-21 09:44:18
【问题描述】:

我在 UITableView 中实现了延迟加载,

其中,我正在从服务器下载图像,而服务器包含不同大小的图像..

并像这样显示,

: 图像显示正确,但问题是 UITableViewCell 文本未正确显示在单行中,正如您在 UITableViewCell Text 的图像对齐中看到的那样,它不在单行中

意味着:单元格 0 到单元格 4 可以正确显示,因为服务器包含的单元格 0 到单元格 4 大小为 100*100 的图像,但单元格 5 和单元格 6 的对齐方式不同,因为服务器包含大小不同的图像85*85

有什么方法可以让我在单行中设置文本对齐方式??

提前致谢。

【问题讨论】:

  • 为什么你不使用自定义单元格..?并根据文本设置单元格的高度
  • 对比这个,你不觉得custom会很慢吗?

标签: iphone ios ipad uitableview


【解决方案1】:

我建议您使用带有 One image-viewLabel 的 Custom table-cell 并设置 Imageview contentMode 如下所示

imageView.contentMode = UIViewContentModeScaleAspectFill; //will fill the frame

imageView.contentMode = UIViewContentModeScaleAspectFit;  //will show the entire image, possibly leaving areas of the frame open. 

和您的标签集 Number of Line 0

【讨论】:

    【解决方案2】:

    我认为自定义 TableView 单元会为您解决问题。 您可以像下面这样设计一个单元格 https://www.dropbox.com/s/r9r6dsmdwmpk50h/customcell.png

    【讨论】:

    • 自定义 TableView Cell 工作正常,但是如何设置 UIImageView 的动态高度?
    【解决方案3】:

    你可以使用 imageView.contentMode = UIViewContentModeScaleAspectFit;

    根据图像大小调整 imagview 的宽度和高度

    【讨论】:

      猜你喜欢
      • 2012-05-23
      • 2021-04-23
      • 1970-01-01
      • 1970-01-01
      • 2012-08-07
      • 2019-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多