scribblelover27 scribblelover27 - 2 years ago 154
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 Source

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

dispatch_async(dispatch_get_main_queue()) {
    progressView.setProgress(progress, animated: true)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download