我有一个UITableViewCell
显示文本和可选的图像。然而,当图像显示时,它变得有点bug,因为在-(void)prepareForReuse:
我将tableViewCell
的imageCell
设置为零,并且滚动图像需要每次加载。UITableView滚动越野车由于prepareForReuse当图像在单元格中
在我customTableViewCell.m
,这是我使用以备再用代码:
- (void)prepareForReuse {
[super prepareForReuse];
self.noteLabel.text = nil;
self.textLabel.text = nil;
self.imageCell.image = nil;
self.personImage = nil;
}
通过删除行self.imageCell.image = nil;
一些细胞会复制其它UITableViewCells
的imageCell
,所以我必须使用prepareForReuse
方法。
有没有什么办法可以将imageCell
设置为零,如果它有所有的单元格加载时的图像?我试过
if(self.iamgeCell.image == nil){
self.imageCell.image = nil;
}
在我试着说:如果imageCell
重用之前为空,请将其设置为nil重用准备的时候,却没有工作这么好。
该如何我目前加载图像中的cellForRowAtIndex
方法:
PFFile *imageFile = [payment objectForKey:@"img"];
if(![imageFile isEqual:@""]){
[imageFile getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {
if (!error) {
UIImage *image = [UIImage imageWithData:imageData];
cell.imageCell.image = [self imageWithImage:image scaledToWidth:cell.imageCell.frame.size.width ];
}
}];
}
这是一个“它不是越野车 - 这就是它的工作方式!” – Fattie 2014-10-18 14:25:54