adriennemhenry adriennemhenry - 2 years ago 138
iOS Question

How do I show the progress of a PFFile download inside a PFImageView

Does anybody know how to set the Progress View Bar for a PFImageView, that is downloading a PFFile from ( I can't find any tutorials on how to do so. (I don't want to set an activity indicator since I'm loading an image and I want the user to know how long he/she will wait).


Answer Source

PFImageView methods are quite limited, you can just use loadInBackground , with or without a completion block. In none of these methods a progressBlock is available.

A workaround would be not to assign a PFFile to a PFImageView, but instead load it with a method using a progressBlock parameter.

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

This is not as simple as [myPFImageView loadInBackground], but I can't see any other way to get a progress indicator. Note that using a PFImageView is no longer necessary in this case, a simple UIImageView will be sufficient. Maybe one day Parse team will add a progressBlock to their PFFile methods !

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download