Re: Redrawing a superview from another view's -drawRect: method
Re: Redrawing a superview from another view's -drawRect: method
- Subject: Re: Redrawing a superview from another view's -drawRect: method
- From: Ricky Sharp <email@hidden>
- Date: Mon, 02 May 2005 08:55:50 -0500
On Monday, May 02, 2005, at 08:34AM, Nick Zitzmann <email@hidden> wrote:
>In Panther, it was possible to get another view and _only_ that view
>to redraw itself by calling -setNeedsDisplay: with YES on the view
>inside another view's -drawRect: method.
>
>In Tiger, it seems that the call to -setNeedsDisplay: is ignored. And
>if I try to manually tell it to display in the same spot where -
>setNeedsDisplay: used to be, then that view calls the other view's -
>drawRect: method and creates an infinite loop. If I make the run loop
>call -display on the view when the run loop is next available, then
>the infinite loop is avoided, but the CPU spikes to 100% because it's
>constantly redrawing the two views.
>
>Is there a way to get the Panther drawing behavior back? If so, then
>what should I do?
Calling setNeedsDisplay: from within drawRect: (or any other drawing methods) is not a good thing to do. Even if you're sending that message to a different view.
I would restructure your code such that setNeedsDisplay is only called from within say accessors. For example, when changing a view's attribute, you often instruct it that it now needs displaying.
In your case, it sounds like the other view is a sibling view? If that's the case, why not do the right thing in your controller layer? You can even create custom bindings in both your views to appropriate models. Whenever the model changes, both views will utlimately be redrawn with their new attributes.
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden