Custom UITableViewCell with Progress Bar download update

前端 未结 3 1585
忘掉有多难
忘掉有多难 2020-12-10 07:33

I am trying to update a each table cell with progress bar loading, but I am stuck. I created a custom cell for a table view with these properties:

@interface         


        
3条回答
  •  -上瘾入骨i
    2020-12-10 07:47

    You should keep the value of (double)totalBytesWritten / (double)totalBytesExpectedToWrite in OFPVideoDetails (add one property "progress" in OFPVideoDetails).

    Then reload the cell in - (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite: (int64_t)totalBytesExpectedToWrite

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        OFPTableCell *cell = [self.tableViewCache dequeueReusableCellWithIdentifier:@"Cell"];
        OFPVideoDetails *vd = [someArray objectAtIndex:indexPath.row];
        cell.textLabel.text=vd1;
        cell.detailTextLabel.text=vd2;
        CGSize size = {65,53};
        cell.imageView.image =[self imageWithImage:[UIImage       imageWithContentsOfFile:vd.imageUrl] scaledToSize:size];
        cell.progressView.progress = vd.progress;
        cell.delegate = self;
        return cell;
    }
    

提交回复
热议问题