我有一個奇怪的問題。我使用具有類似於表視圖控制器的方法,其我已經定義如下的AQGridView:AQGridView中的進度條(類似於TableView)
- (AQGridViewCell *)gridView:(AQGridView *)aGridView cellForItemAtIndex:(NSUInteger)index
{
static NSString *CellIdentifier = @"IssueCell";
AQGridViewCell *cell = (AQGridViewCell *)[gridView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
[[NSBundle mainBundle] loadNibNamed:@"IssueCell" owner:self options:nil];
cell = [[AQGridViewCell alloc] initWithFrame:self.gridViewCellContent.frame
reuseIdentifier:CellIdentifier];
[cell.contentView addSubview:self.gridViewCellContent];
cell.selectionStyle = AQGridViewCellSelectionStyleNone;
}
IssueCell *content = (IssueCell *)[cell.contentView viewWithTag:1];
//This model object contains the title, picture, and date information
IssueModel *m = (IssueModel *)[self.issues objectAtIndex:index];
//If we have already downloaded the file, set the alpha to 1
if ([m hasPdfBeenDownloaded])
{
content.downloadIcon.hidden = YES;
content.imageView.alpha = 1;
content.progressView.hidden = YES;
}
else
{
if (m.pdfDownloadRequest && m.pdfDownloadRequest.isExecuting)
{
content.downloadIcon.hidden = YES;
content.imageView.alpha = .2;
content.progressView.hidden = NO;
}
else
{
content.downloadIcon.hidden = NO;
content.imageView.alpha = .2;
content.progressView.hidden = YES;
}
}
content.title.text = m.title;
// Only load cached images; defer new downloads until scrolling ends
if (!m.coverImageIcon)
{
if (self.gridView.dragging == NO && self.gridView.decelerating == NO)
{
[self startIconDownload:m forIndex:index];
}
content.imageView.image = [UIImage imageNamed:@"grid_cell_loading.png"];
}
else
{
content.imageView.image = m.coverImageIcon;
}
return cell;
}
我的問題是,因爲細胞被重新使用,我失去正確的進度指示和更新它。我使用ASIHTTP如下:
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:model.issuePdfUrl];
request.userInfo = [NSDictionary dictionaryWithObjectsAndKeys:ic, @"cell", model, @"model", nil];
model.pdfDownloadRequest = request;
[request setShouldContinueWhenAppEntersBackground:YES];
[request setDelegate:self];
[request setDownloadDestinationPath:mediaPath];
[request setDownloadProgressDelegate:ic.progressView];
[request startAsynchronous];
我遇到的問題是,當我向下滾動,然後滾動備份,我失去了我曾經有一個可重複使用的電池使用progressView。
這樣做的正確方法是什麼,所以我不失去進度視圖?
謝謝我最終改變了downloadProgressDelegate – 2011-12-26 23:36:28