【发布时间】:2014-09-12 14:42:11
【问题描述】:
我在UITableViewCell 上有一个UIImageView
当我没有要查看的图像时,我希望它消失。
我已经实现了这段代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ((item.content_image != nil) && (item.content_image != (id)[NSNull null]))
{
[cell.imageContentImage setImageWithURL:[NSURL item.content_image]] ;
}
else
{
cell.imageContentImage = nil;
}
}
我收到一位用户的报告,指出单元格中的图像有误(它似乎与其他单元格中的图像重复)。
问题是它不会发生在模拟器或我可以调试它的设备上,所以我的问题变成了理论:
将nil 分配给UIImageView 是正确的方法吗?有没有“更正确”的方法?
【问题讨论】:
-
贴出来的代码是用什么方法的?
-
cellForRowAtIndexPath。编辑代码...
-
首先,我肯定会将 imageView 的图像设置为 nil 而不是 imageView 本身。如果您重复使用您的单元格,您可能会出现意外行为。
-
那么 nil out image 和 nil the entire UIImageView 有什么区别呢?
标签: ios objective-c uitableview uiimageview