Callbacks When an NSScrollView is Scrolled?

Update for Swift 4:

scrollView.contentView.postsBoundsChangedNotifications

Also the call is:

NotificationCenter.default.addObserver(self,
                                       selector: #selector(boundsChange),
                                       name: NSView.boundsDidChangeNotification,
                                       object: scrollView.contentView)

Edit: the collection in mac doesn't inherit from scrollview. updated properly


Had the same problem recently... To somewhat emulate deceleration callbacks it is possible to override

-(void) scrollWheel:(NSEvent *)theEvent 

of NSScrollView class, but then check theEvent.momentumPhase instead of theEvent.phase for event phases.


You can monitor a scroll view's changes by monitoring the bounds of it's content view. First set the content view to post its changes with

[contentView setPostsBoundsChangedNotifications:YES];

Then register as an observer of those notifications with

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(boundsDidChange:) name:NSViewBoundsDidChangeNotification object:contentView];