NSProgressIndicator animation and redraw
Q:
Why doesn't my NSProgressIndicator
redraw every time I update it's value?
A: Why doesn't my NSProgressIndicator
redraw every time I update it's value?
When an update to NSProgressIndicator
is needed, when its value changes, or you call animate:
, an event to redraw the view is added to the event queue and will be processed the next time events for that view are dispatched.
To ensure the progress bar redraws at once, you need to call:
[progressIndicator displayIfNeeded];
This will force pending events out of the standard queue and have them reflected on-screen immediately.
Listing 1 Example of using NSProgressIndicator
control in a loop.
[progressIndicator setMaxValue: (double)count]; //... for (loopIndex = 0; loopIndex < count; loopIndex++) { // do some work... [progressIndicator setDoubleValue: (double)loopIndex]; [progressIndicator displayIfNeeded]; } |
Document Revision History
Date | Notes |
---|---|
2006-11-15 | New document that discusses why NSProgressIndicator does not redraw during progress loops. |
Copyright © 2006 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2006-11-15