for循环中异步的图像方式 [英] Asynchronus way of image in for loop
本文介绍了for循环中异步的图像方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个for循环,其中包含uiimageview,每次我从数组中添加url的图像,我将其转换为数据和imagewithdata方法使用它,它对我来说很完美,但它需要很长时间时间,我们可以在uitableview中使用延迟加载吗?
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?
请帮助
提前致谢
推荐答案
我在UItableView中使用了以下方式,而不是滚动问题,而不是滚动问题。
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;
});
这篇关于for循环中异步的图像方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文