我在我的項目中使用了ASIHTTPRequest框架來處理所有與網絡有關的任務。ASIHTTPRequest同時下載桌面視圖上的圖像需要時間
我有自定義單元格與來自web服務器的縮略圖,有大約500個圖像,所以我不得不重複使用單元格來處理它。當我們滾動瀏覽tableview時,由於重複使用單元格,我們可以看到之前單元格的圖像,這些圖像將被新圖像替換。
如果網絡連接低,它更糟糕,因爲它需要大量的時間來下載圖像..所以當時你可以看到特定的錯誤圖像,因爲重新使用單元格,所以我需要找到方法,以便這種圖像替換不應該'用戶不可見。
我正在使用ASIDownalod SharedCache方法。
編輯
NSString *reuseIdentifier = @"offerCell";
BRZOfferCell *offerCell = (BRZOfferCell*)[tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
if (offerCell==nil) {
offerCell = [[[BRZOfferCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier celltype:kDealCellTypeDealsList] autorelease];
}
[offerCell setImage:[UIImage imageNamed:IMAGE_NO_IMAGE]];
//---get the letter in the current section---
//NSString *alphabet = [mDealsIndex objectAtIndex:[indexPath section]];
//---get all deals beginning with the letter---
NSString* lSectionIndex = [NSString stringWithFormat:@"%i",[indexPath section]];
NSMutableArray *deals = [mIndexedOffersDic objectForKey:lSectionIndex];
if ([deals count]>0) {
//---extract the relevant deal from the deals array object---
Offer* lOffer = [deals objectAtIndex:indexPath.row];
[offerCell setOffer:lOffer];
offerCell.accessoryView = UITableViewCellAccessoryNone;
if (mTableView.dragging == NO && mTableView.decelerating == NO)
{
//Function : format image url to [email protected] and Initiate Image request download
//and set cache policy
[mListViewHelper InitImageRequest: lOffer.PromoImage indexPath: indexPath];
}
}
return offerCell;
這將有助於看到您的UITableView委託方法 – aryaxt 2011-12-15 05:08:06