如何在PFImageView中显示PFFile下载的进度

adr*_*nry 2 progress uiprogressview ios parse-platform progress-bar

有没有人知道如何为PFImageView设置进度视图栏,即从(Parse.com)下载PFFile?我找不到任何有关如何操作的教程.(我不想设置活动指示器,因为我正在加载图像,我希望用户知道他/她将等待多长时间).

谢谢!

Mic*_*edo 5

PFImageView方法非常有限,你可以只使用loadInBackground,有或没有完成块.在这些方法中,都没有progressBlock可用.

解决方法是不将PFFile分配给PFImageView,而是使用progressBlock参数通过方法加载它.

[myImageFile getDataInBackgroundWithBlock:^(NSData * result, NSError *error)
{ 
     if (result != nil && error == nil)
     {
          [myImageView setImage:[UIImage imageWithData:result]];
     }
     else
     {
          // handle the error
     }
 }
 progressBlock:^(int percentDone)
 {
     [progressView setProgress:(float)percentDone/100.0f];
 }];
Run Code Online (Sandbox Code Playgroud)

这不像[myPFImageView loadInBackground]那么简单,但是我看不到任何其他方法来获取进度指示器.请注意,在这种情况下不再需要使用PFImageView,简单的UIImageView就足够了.也许有一天,Parse团队会在他们的PFFile方法中添加progressBlock!