问题
I have an for loop , which consists of uiimageview inside it, everytime i add the image from the array which consits of url , i convert it to data and imagewithdata method am using it, it works for me perfectly but it takes long time , can we acheive it in lazy loading which is used in uitableview?
Pls help
Thanks in advance
回答1:
Instead of Lazzy Loading I used following way in UItableView and its working for me without scrolling issue .
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^(void) {
NSData *imageData ;
imageData = [UICommonUtils imageDataFromString:profile.Photo];
dispatch_sync(dispatch_get_main_queue(), ^(void) {
if([imageData length] > 1)
{
//UIImageView* imageView = (UIImageView*)[cell viewWithTag:100];
cell.ProfileImage.image = [UIImage imageWithData:imageData];
}
else
{
cell.ProfileImage.image = [UIImage imageNamed:kDefaultProfileImage];
}
});
imageData = nil;
});
来源:https://stackoverflow.com/questions/18510909/asynchronus-way-of-image-in-for-loop