Ios UIImageView特性适合在tableview滚动时不工作
我使用下面的代码将图像缩放到UIImageView。第一次加载表时,一切正常。但当我滚动tableview时,所有图像方面都被破坏了Ios UIImageView特性适合在tableview滚动时不工作,ios,objective-c,uitableview,uiimageview,Ios,Objective C,Uitableview,Uiimageview,我使用下面的代码将图像缩放到UIImageView。第一次加载表时,一切正常。但当我滚动tableview时,所有图像方面都被破坏了 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Pro
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ProductCell" forIndexPath:indexPath];
[self configureCustomCell:(ProductsTableViewCell*)cell atIndexPath:indexPath];
return cell;
}
- (void)configureCustomCell:(ProductsTableViewCell*)cell atIndexPath:(NSIndexPath *)indexPath {
NSURL *url = [NSURL URLWithString:[[arr_products objectAtIndex:indexPath.section] productImage]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
__weak UITableViewCell *weakCell = cell;
[cell.productPhotoImage setImageWithURLRequest:request placeholderImage:nil
success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
weakCell.imageView.image = image;
weakCell.imageView.contentMode = UIViewContentModeScaleAspectFit;
weakCell.imageView.clipsToBounds = YES;
weakCell.imageView.frame = CGRectMake(5, 5, 60, 60);
}
failure:nil];
}
如果要从服务器获取映像,然后将其加载到单元格tableviewcell上,则无法正确升级 您可以使用SDWebImage库从服务器加载映像,请检查此链接 如果要添加活动指示器,请选中此项
请在
-tableView:cellforrowatinexpath:
@serdar aylanc中显示您的代码您是否使用自定义单元格???@satheesh我更新了问题中的代码
#import <SDWebImage/UIImageView+WebCache.h>
[weakCell.myImage setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:@"mawgif-log.png"] options:SDWebImageRefreshCached usingActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];