Re: how to redraw a view
Re: how to redraw a view
- Subject: Re: how to redraw a view
- From: Chris Hanson <email@hidden>
- Date: Fri, 26 Nov 2010 03:16:47 -0800
On Nov 24, 2010, at 9:50 AM, Artemiy Pavlov <email@hidden> wrote:
> I have a view whose drawRect method draws a plot according to a few parameters which are global variables. When I change these variables according to the user input, I want to update that plot, so I need the drawRect method of my view to be called. I tried [self setNeedsDisplay] or [MyView setNeedsDisplay] but this doesn't work.
(I assume you're referring to -drawRect: and -setNeedsDisplay:, as the colons are part of Objective-C method names, not separate syntax.)
In what way doesn't this work for you?
Do you mean that after you make a change, your view isn't redrawn the next time through the run loop?
Or do you mean that when you change a property on your view, you expect the view to draw immediately rather than at another part of the run loop?
Finally, and to cover all bases, are you changing the property on your view in the main thread, or in another thread?
You should just ensure changing properties on your view (or property changes on the data your view is observing) causes the view to invoke either [self setNeedsDisplay:YES] or [self setNeedsDisplayInRect:affectedRect]. Cocoa will generally ensure your -drawRect: is invoked at the right time after that.
-- Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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