Пользовательский UITableViewCell с UIProgressView - PullRequest
0 голосов
/ 17 сентября 2011

Я использую ASIHTTPRequest для загрузки файлов.Мой пользовательский UITableViewCell имеет UIProgressView, у него есть свойство UIPRogressView, называемое: downloadProgressView.Когда я нажимаю загрузки больше, чем tableView может отображаться в видимой области, UIProgressView работает странно.Значения UIProgressView в ячейках смешиваются, когда я начинаю прокручивать.Я загружаю файлы асинхронно.

Вот метод для создания новой загрузки.

 -(void) pushDownload:(NSString *) url :(NSString *) fileName
{
    [downloads addObject:fileName];
    [downloadsTableView reloadData];

    NSURL *url = [NSURL URLWithString:url];
        //This is my custom cell
    DownloadCell *cell = (DownloadCell *)[downloadsTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:[downloads indexOfObject:fileName] inSection:0]];
    [cell.deleteDownloadButton setImage:[UIImage imageNamed:@"stop.png"] forState:UIControlStateNormal];
    __block ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:url];
    [request setDownloadDestinationPath:@"somepath"];
    [request setDownloadProgressDelegate:cell.dowloadProgressView];
    cell.currentRequest = request;
    [request setShowAccurateProgress:YES];
    cell.status = Downloading;
    [request startAsynchronous];
}   

А вот код для создания новой ячейки:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
 (NSIndexPath *)indexPath 
  {
static NSString *CellIdentifier = @"myCell";
DownloadCell *cell = (DownloadCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) {
    NSArray *nibs = [[NSBundle mainBundle] loadNibNamed:@"DownloadCell" owner:nil options:nil];

    for (id nibObject in nibs) {
        if ([nibObject isKindOfClass:[DownloadCell class]]) {
            cell = nibObject;

        }
    }
    [cell.deleteDownloadButton setImage:[UIImage imageNamed:@"symbol_stop.png"] forState:UIControlStateNormal];

}

cell.textLabel.text = [audioDownloads objectAtIndex:indexPath.row];
if (cell.status==Downloaded) {
   cell.dowloadProgressView.progress==1.0;
}

return cell;
}

Зачем выполнять прогресс просмотра значенийсмешиваете когда я начинаю прокручивать?Даже когда загрузка завершена, значения все еще иногда смешиваются.

...