R – UIProgressView not updating while the App loads its resources

uiprogressviewuiview

I am trying to update a UIProgressView progress bar that I have in a UIView during a long resource loading process. Let's say I'm loading a bunch of bitmaps from a NIB file (like maybe a hundred). After I load 10, I issue a .progress to the UIProgressView that is part of a UIView that is already being displayed. So, I issue:

myView.myProgressView.progress=0.2;

Then, I load another 10 bitmaps, and issue:

myView.myProgressView.progress=0.4;

etc., etc. When the app runs, the progress bar doesn't advance. It simply stays at its initial position. At the risk of sounding like a complete moron, do I have to load my resources on a separate thread so the OS can update the UI, or, is there an easier way? Thanks for any assistance.

Best Answer

Yes. Load them on a separate thread. Or just use something like performSelector:

[self performSelector:@selector(setProgressBar) withObject:nil afterDelay:0.0];

(and create a setProgressBar function which reads the current value from a member variable and updates the UI)

Related Topic