1

有一个NSTableView包含几个单元格。单元格中有一个NSTextFieldNSProgressIndicator。每个单元格都有自己的进度指示器,代表自己的上传百分比。

现在,我需要根据上传百分比更新进度指示器,以便我们知道上传进度。

- (void)startUploading:(NSArray *)filePathArray
{
if (self.QNToken) {

    NSString *token = self.QNToken;
    NSUInteger count = [filePathArray count];

    // We may have multiple files to upload.

    for (int i = 0; i < count; i ++) {
        NSString *filePath = filePathArray[i];
        NSData *fileData = [NSData dataWithContentsOfFile:filePath];
        NSString *key = [fileData md5String];

        // Upload option

        QNUploadOption *option = [[QNUploadOption alloc] initWithMime:nil
                                                      progressHandler:^(NSString *key, float percent) {
                                                          QNUploadDetailCell *cell = [self.tableView viewAtColumn:0 row:i makeIfNecessary:NO];
                                                          [cell.progress.animator setDoubleValue:percent];
                                                          [cell.progress displayIfNeeded];
                                                      }
                                                               params:nil
                                                             checkCrc:NO
                                                   cancellationSignal:nil];

        // Let's upload!

        [self.uploadManager putFile:filePath
                               key:key
                             token:token
                          complete: ^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
                              NSLog(@"%@", info);
                              NSLog(@"%@", resp);
                          } option:option];
    }
}
}

但是,进度指示器永远不会被动画化。

我还打印出百分比progressHandler:百分比只是从 0 增加到 1.0

但是进度条仍然停止。

在此处输入图像描述

有任何想法吗?

4

0 回答 0