我有一个从我的网址加载图片的TableView,一切都很好。问题是当我向下或向上滚动时,图像在单元格中变大。有时它变得比自己的细胞更大。
我已经尝试了所有的东西,但它不起作用,我坐在View模式下适合Aspect,但仍然有同样的问题。
她是我的代码:
static NSString *cellIdentifier = @"Cell";
CellView *cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
if (!cell) {
cell = [[CellView alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
ListOfObjects *listObjects;
cell.accessoryType = UITableViewCellAccessoryNone;
listObjects = [listArray objectAtIndex:indexPath.row];
cell.userName.text = userName;
ListOfObjects *venue = ((ListOfObjects * )self.listArray[indexPath.row]);
NSString *one = listObjects.theUserId;
NSURL *myUrl = [NSURL URLWithString:one];
if (listObjects.image) {
cell.imageView.image = listObjects.image;
} else {
// set default user image while image is being downloaded
cell.imageView.image = [UIImage imageNamed:@"second58.png"];
// download the image asynchronously
[self downloadImageWithURL:myUrl completionBlock:^(BOOL succeeded, UIImage *image) {
if (succeeded) {
// change the image in the cell
cell.imageView.image = image;
// cache the image for use later (when scrolling up)
venue.image = image;
}
}];
}
任何人都能给我一个关于它的想法吗?
答案 0 :(得分:0)
也许你可以调整图像框的大小:
[self downloadImageWithURL:myUrl completionBlock:^(BOOL succeeded, UIImage *image) {
if (succeeded) {
cell.imageView.image = image;
cell.imageView.frame = your.frame;
}
}];
如果你缓存图片,你应该在使用它时设置它的框架,而不仅仅是当它完成下载时