I am fulfilling a request for a given image resource PHAsset, and I am using UIProgressViewit to indicate progress with the help progressHandler PHImageRequestOptionsthat I can provide. When this handler is called, it provides me progress, so I set progress in representing progress, but I also animate this new progress through setProgress:animated:. Now I need to figure out how to hide the progress as soon as the progress reaches 1.0, but only after it has completed the animation before 1.0.
For example, it can start loading an asset, call a progress callback with 0.2, then the next callback can be 1.0. If I hide the progress bar, as soon as I get 1.0, the user will not see that he will be close to 1.0, he will disappear, perhaps as long as it is 0.7, for example.
My question is, how can I find out when he finished animating the new meaning of progress, so find out when the time is right to hide the idea of progress?
let options = PHImageRequestOptions()
options.networkAccessAllowed = true
options.progressHandler = { (progress: Double, _, _, _) -> Void in
dispatch_async(dispatch_get_main_queue()) {
self.barProgressView.setProgress(Float(progress), animated: true)
self.barProgressView.hidden = (progress <= 0.0 || progress >= 1.0)
}
}
PHImageManager.defaultManager().requestImageForAsset(photoAsset, targetSize: targetSize, contentMode: .AspectFit, options: options) { (result: UIImage?, info: Dictionary?) -> Void in
}
source
share