【问题标题】:What's the default size for the UIImage in a UITableViewCell?UITableViewCell 中 UIImage 的默认大小是多少?
【发布时间】:2011-01-08 11:51:00
【问题描述】:

我想在 UITableView 的每一行的左侧放置一个 UIImage。这是相当标准的,并且由 UIKit 直接支持。但是放入(大)图像会导致各种不稳定,所以大概我应该自己正确缩放这个东西。但是没有一个文档使用标准的开箱即用视图为该图像提供默认大小-我很惊讶。

SO 上的其他人表示 44 是行的默认高度 (What is the default height of UITableViewCell?) 44x44 是“默认”图像尺寸吗?

谢谢!

【问题讨论】:

    标签: iphone uitableview uiimage


    【解决方案1】:

    40x40

    UITableViewCell's imageView fit to 40x40

    需要使 imageView 填充为 40x40...我正在使用 SDK 3.0 并内置“预定义样式中的单元格对象”...

    【讨论】:

    • 在视网膜中,tableviewcell 中的图像大小是多少?是80*80吗?
    • @Dee 是的,它对应于视网膜中的 80x80 哟
    【解决方案2】:

    我正在为 iOS 6.1 构建 Xcode 4.6.3。我尝试了分配给 UITableViewCell 的imageView 的 2 种图像尺寸:48x48 和 128x128 像素。这是在 iOS 模拟器 (iPad) 中运行的。

    在 UITableViewDelegate 中,我将下面这行放在tableView:didSelectRowAtIndexPath: 中,并在其后放置一个断点。

    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
    

    在 lldb 中,我得到以下输出:

    (lldb) po cell
    $0 = 0x0751a720 <UITableViewCell: 0x751a720; frame = (0 88; 180 44); text = 'widget'; autoresize = W; layer = <CALayer: 0x751a6f0>>
    (lldb) po cell.imageView
    $1 = 0x0751a1e0 <UIImageView: 0x751a1e0; frame = (0 0; 43 43); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x751a1b0>>
    

    基于此证据我能得出的唯一结论是默认图像尺寸不是 40x40。

    【讨论】:

      猜你喜欢
      • 2011-03-22
      • 1970-01-01
      • 1970-01-01
      • 2012-01-01
      • 2010-10-10
      • 2014-01-11
      • 1970-01-01
      • 2010-12-07
      • 2013-08-28
      相关资源
      最近更新 更多