在我的應用程序中,我在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的異步圖像加載'谷歌會給你指針爲你的問題。 –