scribblelover27 scribblelover27 - 7 months ago 10
Swift Question

UIProgressView setProgress

I am attempting to implement a UIProgress view. I run the function setProgress each time the end of an iteration is performed in a for loop. The progress is set like this:

let progress: Float = Float(i + 1) / Float(list.count)


And the progress function looks like this:

progressView.setProgress(progress, animated: true)


Yet, the progress bar is not updated on each loop. Why is this?

Answer

you should do it in your main queue with the async method

dispatch_async(dispatch_get_main_queue()) {
    progressView.setProgress(progress, animated: true)
}