PDA

View Full Version : Problem with a NSProgressIndicator




mpemburn
Jun 24, 2009, 08:21 PM
Hi,

I've added an NSProgressIndicator to the splash screen of my app (since it can take a while to locate the resources necessary to load the main window). I wanted to have a "Bar" type indicator but nothing I've been able to do will make it move as it should. When I change it to the "Spinning" type, it works just fine but the Bar just sits there.

The indicator is connected to the app controller via:

IBOutlet NSProgressIndicator * splashProgress;

. . . and this is the code that runs it:


[splashProgress setHidden: NO];
[splashProgress startAnimation: self];


Any ideas?

-- Mark



kainjow
Jun 24, 2009, 08:23 PM
Are you sure the indeterminate checkbox is on in IB?

mpemburn
Jun 24, 2009, 08:32 PM
Wow -- that was fast! Yes, it's checked.

-- Mark

kainjow
Jun 24, 2009, 08:46 PM
I'd double-check your IB connections. Make sure you're calling the code after/during awakeFromNib (e.g. make sure your progress is non-nil). etc..

mpemburn
Jun 24, 2009, 09:11 PM
I'd double-check your IB connections. Make sure you're calling the code after/during awakeFromNib (e.g. make sure your progress is non-nil). etc..

The IB connections are definitely there and working and the code that calls loads the splash screen (including the calls to the progress indicator) is right at the top of awakeFromNib. In order to prove that the connection is valid, I've comment out the "startAnimation" line, and see a stopped spinner when the screen loads. When I un-comment it again, the spinner animates. If I add the line:


[splashProgress setStyle: NSProgressIndicatorBarStyle];


. . . it'll change to the bar style but not move.

-- Mark

rossipoo
Jun 24, 2009, 10:28 PM
If you want it to show the progress, indeterminate should be off. Indeterminate means that it does NOT show the amount of progress, but only that the application is "busy".

Are you updating the progress value with setDoubleValue regularly throughout your loading process?

mpemburn
Jun 25, 2009, 05:50 AM
In this case, I don't really have any progress to show -- it's waiting for a dylib to recognize all imaging devices attached to the system -- so "indeterminate" is the appropriate mode. Like I have said, the Spinner works in indeterminate mode and the Bar does not.

Think I'll try a dummy project to see if the problem is universal or some quirk in this app. I've had some other annoying phenomena, such as controls that stop appearing after I make some unrelated change to the panel. I would just hate it if there's something wrong with the NIB -- I've put a lot of time into this interface.

-- Mark

kainjow
Jun 25, 2009, 08:13 AM
The only other thing I can think of is the progress bar is somehow being blocked from animating, but I believe on 10.5+ the default is setUsesThreadedAnimation:YES so that shouldn't be a problem even if you're blocking the main thread. I would agree on the dummy project because I think either something is borked with your project or you're just forgetting to do something small.

Eraserhead
Jun 25, 2009, 02:40 PM
I've had problems with NSProgress indicators if I didn't do the work in another thread so that is probably the best way forward.

mpemburn
Jul 12, 2009, 08:28 AM
Figured out an acceptable workaround -- set the values to: Minimum = 0.0, Maximum = 100.0 and Current = 99.0. As long a the bar is reasonably short, there's no visible difference between being 99% done and 100% done so the bar shows motion across its full length.

-- Mark