// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"celluleConnecte";
celluleConnecte *cell = (celluleConnecte *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
UIViewController *vue = [[UIViewController alloc] initWithNibName:@"celluleConnecte" bundle:nil];
cell = (celluleConnecte *)vue.view;
[vue release];
}
else {
asyncImageView* oldImage = (asyncImageView*)
[cell.contentView viewWithTag:999];
[oldImage removeFromSuperview];
}
// Configure the cell.
NSDictionary *dico = [self.pseudoOnline objectAtIndex:indexPath.row];
cell.pseudo.text = [dico objectForKey:@"name"];
cell.sexe.text = [dico objectForKey:@"sexe"];
CGRect frame;
frame.size.width=70; frame.size.height=70;
frame.origin.x=5; frame.origin.y=10;
asyncImageView *asyncImage = [[[asyncImageView alloc] initWithFrame:frame] autorelease];
asyncImage.tag =999;
[asyncImage loadImageFromURL:[NSURL URLWithString:[dico objectForKey:@"photo"]]];
[cell.contentView addSubview:asyncImage];
return cell;
}
回答
這是因爲您在單元格中正確下載圖像,這是錯誤的。創建一個新類UIImageView
並使用NSData
在那裏下載照片。互聯網上有很多例子。這裏是我第一次發現markj.net/wp/wp-content/uploads/2009/02/asyncimageview.m
嗨,我看到已經這個例子,但不明白..當你充滿細胞與這個cell.picture.image = [UIImage imageWithData:[NSData的dataWithContentsOfURL:[NSURL URLWithString:[dic objectForKey的:@ – XcodeMania 2011-06-02 22:25:47
:@ 「url」]]]];'程序每次都下載圖片,所以這是很慢的。你必須做異步下載,並做到這一點,你必須創建一個類,它應該加載圖像,並在單元格中初始化它。 – sherilyn 2011-06-03 05:45:18
現在沒事了。這很好,但還有一件事。當我向下滾動時,我可以看到圖像良好的順序,但是當我向上滾動時圖像不是很好。我需要等待1或2秒才能看到好的圖像。 – XcodeMania 2011-06-08 19:22:08
- 1. 更新數據後重繪UITableView異步
- 2. VoiceOver和異步UITableView
- 3. 的UITableView和異步請求
- 4. ASIHTTPRequest異步更新uitableview
- 5. 是 - [UITableView reloadData]異步還是同步?
- 6. 異步下載的問題UITableView
- 7. 的UITableView行上點擊異步
- 8. node.js中的異步讀取數據庫
- 9. Vue.js過濾器中的異步數據
- 10. 異步獲取URL中的數據
- 11. Angular中的異步數據處理
- 12. 高圖中的異步數據輸入
- 13. Perl中的異步數據庫和LDAP
- 14. Django中的異步數據庫更新?
- 15. UITableView中的數據與iOS5中的TWRequest同步
- 16. 異步更新數據庫
- 17. 異步數據傳輸CUDA
- 18. AngularJs異步數據綁定
- 19. 異步SMPP附加數據
- 20. 異步數據和WCF?
- 21. 異步返回數據
- 22. Angular2 rxjs數據異步
- 23. 自動完成UITextField異步更新UITableView
- 24. 異步圖像加載UITableView問題
- 25. UITableView和異步加載與NSURLconnection
- 26. 使用KIF測試異步UITableView
- 27. 在ember-data中異步加載數據
- 28. 在AngularJS中加載異步數據
- 29. NodeJs中的異步函數
- 30. Winsock中的數組異步
你的問題是什麼?您如何實現異步下載數據? – 2011-06-02 19:13:32
是的。我不知道如何 – XcodeMania 2011-06-02 22:24:56