문제

Hi i am using sync api for download images from DBx and sync my app data to DBX. Now i want to download images from DBX with progress bar. I tried this but i could not any progress value and get downloaded with this warning. This is my code

 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];             }
         }];
    }

Warning is :- dropbox_file_wait_for_ready should not be called on the main thread

도움이 되었습니까?

해결책

@rmaddy is right... calling readData before the file has finished downloading will cause that call to block, and so you won't see any progress. (That's also presumably causing the warning.)

If you don't do that, you should be able to see progress as the file downloads, but it looks like you haven't implemented that part yet.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top