• 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: needsDisplay and subviews
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: needsDisplay and subviews


  • Subject: Re: needsDisplay and subviews
  • From: Quincey Morris <email@hidden>
  • Date: Wed, 08 Mar 2017 17:49:39 -0800

On Mar 8, 2017, at 15:25 , Jeremy Hughes <email@hidden> wrote:
>
> My conclusion (for now) is that “needsDisplay” causes subviews to be redrawn - except when “wantsLayer” has been set to true.
>
> Does that make sense?

Sure. In some cases, such as when using layers, the result of your “draw(_:)” methods for custom subviews can be skipped as an optimization, since their output might have been cached earlier in a backing store.

“needDisplay” applies to the view(s) for which it is set. That means the “draw(_:)” method is called for that view (or those views). However, in a later part of the screen update process, this new drawing output must be composited with subview drawing output.

For subviews that didn’t have “needsDisplay” set, this compositing can be done with the existing backing store, if available. Otherwise, the subview “draw(_:)” methods have to be called too, simply to (re)create the subview contents. It can be difficult to predict which drawing paths will be taken.

One situation where subviews may already be cached is when you are using layers, since layers *are* drawing caches.

So, the correct answer to your original question, I think, is that if your model data has changed in such a way that the representation in custom views no longer reflects the data, then you should set “needsDisplay” on *every* custom subview that uses “draw(_:)”.

If you just need your changed view to be re-composited with the same subview contents as previously, then you don’t need to set “needsDisplay” on the subviews, just the parent view.
_______________________________________________

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: needsDisplay and subviews
      • From: Jeremy Hughes <email@hidden>
References: 
 >needsDisplay and subviews (From: Jeremy Hughes <email@hidden>)
 >Re: needsDisplay and subviews (From: Ben Kennedy <email@hidden>)
 >Re: needsDisplay and subviews (From: Jeremy Hughes <email@hidden>)

  • Prev by Date: Re: needsDisplay and subviews
  • Next by Date: Re: needsDisplay and subviews
  • Previous by thread: Re: needsDisplay and subviews
  • Next by thread: Re: needsDisplay and subviews
  • Index(es):
    • Date
    • Thread