Loading takes a while when i set UIImage to a NSData with a url.

前端 未结 6 1609
独厮守ぢ
独厮守ぢ 2020-12-21 19:33
NSData *imageUrl = [NSData dataWithContentsOfURL:[NSURL URLWithString:[[self.content objectAtIndex:indexPath.row] valueForKey:@\"imageUrl\"] ]];
cell.thumbnailImageV         


        
6条回答
  •  一向
    一向 (楼主)
    2020-12-21 20:11

    use sdwebimage and down load the library file from here

    the few steps you do follow

    add the sdwebimage in your project after that

    in your .h file

    #import "UIImageView+WebCache.h"
    

    in your .m file

    call the single line in your cellforRowAtIndexPath

    [cell.thumbnailImageView setImageWithURL:[NSURL URLWithString:[[self.content objectAtIndex:indexPath.row] valueForKey:@"imageUrl"]]
                                         placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    

提交回复
热议问题