在我的应用程序中,我在cellforrowatindexpath中加载单元格的照片,但它需要长时间的主线程,而当我滚动时,我的应用程序停止了一段时间。 我该怎么办?如果我添加异步线程,它会在每次滚动时调用它,并且可能有2个或更多相同的照片加载请求,这不是很好......没有任何想法没有意大利面条编码?异步加载在uitableview中的照片
0
A
回答
2
尝试SDWebImage框架
https://github.com/rs/SDWebImage
示例代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:MyIdentifier];
}
// Here we use the new provided sd_setImageWithURL: method to load the web image
[cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"Get each url from array and set it here using indexpath.row"]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
cell.textLabel.text = @"My Text";
return cell;
}
它支持多种像缓存等特征
+0
使用“https://github.com/JJSaccolo/UIActivityIndicator-for-SDWebImage”它将帮助您显示活动指示器,直到图像加载完成。 –
相关问题
- 1. 在UITableView中实现异步加载照片的最佳方法
- 2. 异步加载 - UITableView和Firebase
- 3. 在iPhone上UITableView异步加载JSON
- 4. 在gridview中异步加载图片
- 5. 在FragmentPagerAdapter中异步加载碎片
- 6. 异步加载图片
- 7. 在下载时异步加载UITableView中的图像
- 8. 异步图像加载UITableView问题
- 9. UITableView和异步加载与NSURLconnection
- 10. 添加照片,定制uitableview
- 11. 空滚动视图和异步加载照片
- 12. 如何从后台加载许多照片url(异步)
- 13. 创建线程和加载照片异步
- 14. 在uitableview中异步加载的图像在滚动时消失
- 15. Swift在UITableView中异步加载图像 - 顶部单元格没有图片
- 16. 异步的图片加载等待
- 17. 使用GCD在UITableView中异步加载图像
- 18. 在UITableView中使用Autolayout异步加载图像
- 19. 在uitableview单元格中加载异步图像
- 20. 异步加载图片黑莓
- 21. 异步加载
- 22. 在UITableView中加载几张图片
- 23. 异步下载的问题UITableView
- 24. Android的:加载照片
- 25. UITableView中的异步数据
- 26. jquery如何在div中加载照片?
- 27. UITableView reloadData异步
- 28. 异步下载图片
- 29. ANDROID:在列表中加载异步图片
- 30. 延迟加载的照片在UIscrollview
写作 '在表视图iOS的异步图像加载'谷歌会给你指针为你的问题。 –