加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

objective-c – UITableViewCell图像未更新

发布时间:2020-12-14 18:59:20 所属栏目:百科 来源:网络整理
导读:我可以更新detailTextLabel.text,UITableViewCell在运行时显示更改,但如果我尝试更新imageView.image,它不会更改可见图像.知道为什么?我曾尝试在UITableViewCell上调用刷新,但无济于事. -(void)getImageForURL:(NSURL*)url row:(UITableViewCell*)cell { UI
我可以更新detailTextLabel.text,UITableViewCell在运行时显示更改,但如果我尝试更新imageView.image,它不会更改可见图像.知道为什么?我曾尝试在UITableViewCell上调用刷新,但无济于事.

-(void)getImageForURL:(NSURL*)url row:(UITableViewCell*)cell {

    UIImage*image;

    image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url];

    cell.imageView.image = image; // Does not work..
    cell.detailTextLabel.text = @"test"; // Works

}

解决方法

确保单元格样式为UITableViewCellStyleDefault,因为其他单元格类型可能始终返回nil imageView,而不是按需创建一个.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读