• 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: [NSView noob] How to be detect when a scroll view scrolls its document view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSView noob] How to be detect when a scroll view scrolls its document view


  • Subject: Re: [NSView noob] How to be detect when a scroll view scrolls its document view
  • From: Graham Cox <email@hidden>
  • Date: Wed, 1 Apr 2009 12:13:13 +1100


On 01/04/2009, at 10:01 AM, Stuart Malin wrote:

I have an NSScrollView with a document view that contains many subviews. I need to perform some processing on these views as they become visible or not visible because of scrolling of the ScrollView. I'm sure this must be straightforward to detect, but alas, I don't have a deep enough understanding of Views and ClipViews and ScrollViews. I've looked at the Cocoa Views Guide, and pertinent class documentation, but the requisite means have not been obvious to me. I've looked either for some kind of notification to register for, or a method to override. I have tried registering for the NSViewFramDidChangeNotification of the scroll view's clipView, but seem to only receive that on a resize, and not on scrolling. I suspect what I need to know is when the documentVisibleRect (or visibleRect) changes... I'd appreciate any pointers regarding what I should be looking at to devise a solution. TIA.


You're overthinking this.

-drawRect: will be called with the area needing update, as it is revealed by scrolling. You can then just draw what intersects that rect, or use -needsToDrawRect:

For embedded subviews, -drawRect: isn't even called if no part of the view is visible.

--Graham


_______________________________________________

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


References: 
 >[NSView noob] How to be detect when a scroll view scrolls its document view (From: Stuart Malin <email@hidden>)

  • Prev by Date: Re: Best Strategy to Control iTunes
  • Next by Date: Re: [BUG] Cursor Flicker
  • Previous by thread: [NSView noob] How to be detect when a scroll view scrolls its document view
  • Next by thread: Measuring time between keypresses?
  • Index(es):
    • Date
    • Thread