【发布时间】:2014-07-24 04:03:17
【问题描述】:
我有一个UITableView,我是这样填写的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyData *myData = [arrayData objectAtIndex:indexPath.row];
MyTableViewCell *cell = [[MyTableViewCell alloc] init:myData.title
:myData.url];
return cell;
}
MyTableViewCell中有一个UIImageView,我是这样加载的:
- (id) init : (NSString *) parTitle : (NSString *) parUrl {
// ...
[self load:parUrl];
// ...
}
- (void) load : (NSString *) url {
NSURL *myURL = [NSURL URLWithString:url];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 18, 70, 65)];
NSData *imageData = [NSData dataWithContentsOfURL:myURL];
dispatch_async(dispatch_get_main_queue(), ^{
// Update the UI
[image setImage:[UIImage imageWithData:imageData]];
image.contentMode = UIViewContentModeScaleAspectFit;
[self.contentView addSubview:image];
[self reloadInputViews];
});
});
}
问题是每次一个单元格从屏幕上消失时,当我向后滚动时它会重新加载其内容,但我不想要它。该怎么办?感谢您的帮助。
【问题讨论】:
-
它被称为细胞重用,你确实想要那个
标签: ios objective-c uitableview