• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: drawRect runs twice, bounds are changed in between
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawRect runs twice, bounds are changed in between


  • Subject: Re: drawRect runs twice, bounds are changed in between
  • From: Quincey Morris <email@hidden>
  • Date: Wed, 14 Jan 2015 06:55:17 +0000

On Jan 13, 2015, at 21:25 , N!K <email@hidden> wrote:
>
> I have not been able to find  a reason for this behavior. . I don’t know how to reveal the point between passes where bounds is actually changed. It does not happen in any other NSView projects of mine; drawRect runs only once in them

The immediate reason is probably that the view’s size changed, which is not unlikely when the window is in the process of being displayed. The view may be resized for a “local” reason, such as the application of auto layout constraints, or for a “global” reason, such as the containing being resized and the change filtering down to subviews.

Another possibility is that the view didn’t change size, but that (as an implementation detail of the Cocoa drawing system) it received two partial invalidations, and these weren’t coalesced in this case.

> I would like to prevent the second pass, or at least prevent the bounds change between passes.

I don’t see any practical way to prevent ‘drawRect’ from being called again. Redundant ‘drawRect’ calls can occur any time during the view’s lifetime.

Are you implying that one bounds rect is “right” and one is “wrong”? If so, how do you know that, and why can’t you just make your code do nothing if the bounds are “wrong”?

If the only criterion is that the *last* bounds rect is “right”, you’ve got a big problem, because there’s no such concept in the drawing system.

If you’re hoping that someone can suggest a solution, you probably need to be more specific about what “right” and “wrong” mean.

> I’m reluctant to try restoring bounds to its first value. I appreciate Ken Thomases’ warning in a previous subject not to change bounds in drawRect.


I’d say it wasn’t a warning, but rather an injunction to never, ever do that. Doing so is Wile E. Coyote stuff.



_______________________________________________

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


  • Follow-Ups:
    • Re: drawRect runs twice, bounds are changed in between
      • From: N!K <email@hidden>
References: 
 >drawRect runs twice, bounds are changed in between (From: N!K <email@hidden>)

  • Prev by Date: Re: drawRect runs twice, bounds are changed in between
  • Next by Date: Advice for iOS web app with live feed
  • Previous by thread: Re: drawRect runs twice, bounds are changed in between
  • Next by thread: Re: drawRect runs twice, bounds are changed in between
  • Index(es):
    • Date
    • Thread