繁体   English   中英

在iOS中使用进度条同步api下载图像

[英]sync api download image with progress bar in ios

嗨,我正在使用sync api从DBx下载图像并将我的应用程序数据同步到DBX。 现在,我想从带有进度条的DBX下载图像。 我尝试了这个,但是我没有任何进展价值,并下载了此警告。 这是我的代码

 DBFile *orignalImg = [[DBFilesystem sharedFilesystem]openFile:imgInfo.imgPath error:nil];
    __weak DBFile *oFile = orignalImg;
    if (oFile)
    {
        [orignalImageArray addObject:oFile]; // make reference of file
    }

    if (orignalImg.status.cached)
    {
        // already displayed
    }
    else
    {
        [orignalImg addObserver:self block:^(void)
         {
             DBFileStatus *fileStatus = oFile.status;
             DBFileStatus *newerStatus = oFile.newerStatus;
             UIImage *aImage = [UIImage imageWithData: [oFile readData:nil]];

             if (fileStatus.cached) // if image downloaded
             {
                 //display image
             }
             else if (fileStatus.state == DBFileStateDownloading) // show progress bar
             {
                  // show progress
                  [self showProgress:strPath andProgressValue:fileStatus.progress];
             }
             else if (newerStatus && newerStatus.state == DBFileStateDownloading)// show progress bar
             {
               [self showProgress:strPath andProgressValue:fileStatus.progress];             }
         }];
    }

警告是:-不应在主线程上调用dropbox_file_wait_for_ready

@rmaddy是正确的...在文件完成下载之前调用readData将导致该调用被阻止,因此您将看不到任何进度。 (这也可能引起警告。)

如果您不这样做,那么应该可以在下载文件时看到进度,但是看来您尚未实现该部分。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM