Точный прогресс, отображаемый с помощью UIProgressView для ASIHTTPRequest в ASINetworkQueue

Резюме: Я хочу отслеживать прогресс загрузки файлов с помощью индикаторов выполнения внутри ячеек табличного представления. Я использую ASIHTTPRequest в ASINetworkQueue для обработки загрузок.
Это работает, но индикаторы выполнения остаются на 0%,и сразу переходите на 100% в конце каждой загрузки.


Подробности: Я настроил свои запросы ASIHTTPRequest и ASINetworkQueue следующим образом:

[Только отрывок из моего кода]

- (void) startDownloadOfFiles:(NSArray *) filesArray {

    for (FileToDownload *aFile in filesArray) {

        ASIHTTPRequest *downloadAFileRequest = [ASIHTTPRequest requestWithURL:aFile.url];

        UIProgressView *theProgressView = [[UIProgressView alloc] initWithFrame:CGRectMake(20.0f, 34.0f, 280.0f, 9.0f)];
        [downloadAFileRequest setDownloadProgressDelegate:theProgressView];

        [downloadAFileRequest setUserInfo:
            [NSDictionary dictionaryWithObjectsAndKeys:aFile.fileName, @"fileName",
                                                        theProgressView, @"progressView", nil]];
        [theProgressView release];

        [downloadAFileRequest setDelegate:self];
        [downloadAFileRequest setDidFinishSelector:@selector(requestForDownloadOfFileFinished:)];
        [downloadAFileRequest setDidFailSelector:@selector(requestForDownloadOfFileFailed:)];
        [downloadAFileRequest setShowAccurateProgress:YES];

        if (! [self filesToDownloadQueue]) {
            // Setting up the queue if needed
            [self setFilesToDownloadQueue:[[[ASINetworkQueue alloc] init] autorelease]];

            [self filesToDownloadQueue].delegate = self;
            [[self filesToDownloadQueue] setMaxConcurrentOperationCount:2];
            [[self filesToDownloadQueue] setShouldCancelAllRequestsOnFailure:NO]; 
            [[self filesToDownloadQueue] setShowAccurateProgress:YES]; 

        }

        [[self filesToDownloadQueue] addOperation:downloadAFileRequest];
    }        

    [[self filesToDownloadQueue] go];
}

Затем в UITableViewController я создаю ячейки и добавляю имя файла и UIProgressView, используя объекты, хранящиеся в словаре userInfo запроса.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"fileDownloadCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        [[NSBundle mainBundle] loadNibNamed:@"FileDownloadTableViewCell" owner:self options:nil];
        cell = downloadFileCell;
        self.downloadFileCell = nil;
    }

    NSDictionary *userInfo = [self.fileBeingDownloadedUserInfos objectAtIndex:indexPath.row];

    [(UILabel *)[cell viewWithTag:11] setText:[NSString stringWithFormat:@"%d: %@", indexPath.row, [userInfo valueForKey:@"fileName"]]];

    // Here, I'm removing the previous progress view, and adding it to the cell
    [[cell viewWithTag:12] removeFromSuperview];
    UIProgressView *theProgressView = [userInfo valueForKey:@"progressView"];
    if (theProgressView) {
        theProgressView.tag = 12;
        [cell.contentView addSubview:theProgressView];
    } 


    return cell;
}

Индикатор выполнения все добавляется, а прогресс установлен на 0%. Затем, в конце загрузки, они мгновенно перескакивают на 100%.

Некоторые загружаемые файлы очень большие (более 40 МБ).

Я не делаю ничего хитрого с потоками.

Читая форумы ASIHTTPRequest, кажется, я не одинок, но я не смог найти решение. Я упускаю что-то очевидное? Это ошибка в ASI *?

7
задан Guillaume 1 July 2011 в 10:04
поделиться