table 添加图像时视图变慢

table view get slower while image adding

我在 table 从数组中获取的视图单元格中添加了图像。 table 视图单元格中正确显示的图像。但是,当我滚动 table 视图时,它会变慢并卡住。帮我写代码。

NSString *imageUrlString = [NSString stringWithFormat:@"http://www.progolmexico.com/static/logo/%@",[[array objectAtIndex:indexPath.row ] valueForKey:@"team_logo"]];
 NSURL * imageURL = [NSURL URLWithString:imageUrlString];
    NSData *data = [NSData dataWithContentsOfURL:imageURL];
  UIImage *cachedImage = [[UIImage alloc] initWithData:data];
    cell.pteam.image = cachedImage;
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
NSString *imageUrlString = [NSString stringWithFormat:@"http://www.progolmexico.com/static/logo/%@",[[array   objectAtIndex:indexPath.row ] valueForKey:@"team_logo"]];
     NSURL * imageURL = [NSURL URLWithString:imageUrlString];
     NSData *data = [NSData dataWithContentsOfURL:imageURL];
     UIImage *cachedImage = [[UIImage alloc] initWithData:data];
    dispatch_async(dispatch_get_main_queue(), ^(void){
     cell.pteam.image = cachedImage;
    });
});