Re: NSImageView does not update in a loop
Re: NSImageView does not update in a loop
- Subject: Re: NSImageView does not update in a loop
- From: Adam Leonard <email@hidden>
- Date: Thu, 15 Feb 2007 21:05:47 -0800
setImage: implies a call to setNeedsDisplay: which does the actual
drawing in the next run loop, which will not occur until the for loop
completes, the method returns, etc.
After you set the image, call [mainImageView display]. That does the
drawing immediately.
Note that the application will still not be responsive (it will not
respond to mouse clicks and it will probably display the spinning
beach ball of death). If you want to ensure the application remains
responsive, you will need to do the processing of the images in a
separate thread. Depending on what you are doing, this may be a
little complicated. Google it to find some documentation on it.
Also, questions like this have appeared many times on this list. In
the future, first search the archives <cocoabuilder.com> before posting
Adam Leonard
On Feb 15, 2007, at 8:50 PM, James Udo Ludtke wrote:
I am processing a batch of images by running through a
for ( i= first; i <= last; i ++) loop.
The image processing works OK, and each processed image is saved in
the loop. The user interface window contains an NSImageView. To
give the user an indication that the images are processed, I like
to show a small thumb image as each image as it is processed.
I have a working method that updates the NSImageView with
[mainImageView setImage:[self thumbImage]];
This line is called once for each image, as it is processed
The NSImageView is updated OK when I convert two images in the
loop. The problem is that when I run a batch of several images, the
NSImageView only updates after the last image has been processed.
The images after the first and before the last never show.
It looks as if the window view is locked while the loop is running.
I have been looking without success for a method to force the
window to update.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden