【问题标题】:UIImage doesn't display in UITableViewUIImage 不显示在 UITableView
【发布时间】:2011-10-08 04:59:42
【问题描述】:

我的 UITableViewCell 中有一个未显示的 UIImageView。我从地址簿中获取图像并将其保存为 NSData 但似乎不起作用。

我有一个获取图像的方法:

if (ABPersonHasImageData(contactrec)){
        CFDataRef imageData = ABPersonCopyImageData(contactrec);
        [person setPic:(NSData *)imageData];
        CFRelease(imageData);
    }

我的 tableviewcell 有以下方法,cellPic 链接到 UIImageView

-(void)setCellPic:(UIImage *) pic{
    cellPic.image = pic;
}

最后,我有一个充满persons 的contactsArray,对于每一行,我都会这样做:

Person *persona =[contactsArray objectAtIndex:indexPath.row];
UIImage *contactImage = [UIImage imageWithData:(NSData *)[persona pic]];
[cell setCellPic:contactImage];

当我调试代码时,似乎角色具有 2000 字节的联系人,但我认为将 NSData 转换为 UIImage 效果不佳。至少,当我调试 setCellPic 时,它说 cellPic.image 是 0x0

感谢您的帮助!

【问题讨论】:

    标签: uitableview uiimage


    【解决方案1】:

    解决了! 问题出在 tableviewcell 中的方法 setCellPic 上。由于 UIImageView 具有相同的 cellPic 名称,编译器认为我正在调用 cellPic 的设置器,但 cellPic 不是 UIImage,它是 UIImageView。所以我更改了方法的名称,现在可以正常工作了! 还是谢谢!

    【讨论】:

      猜你喜欢
      • 2014-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-05
      • 1970-01-01
      • 2021-12-31
      • 1970-01-01
      相关资源
      最近更新 更多