@@ -276,25 +276,6 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
276276#endif
277277
278278#if TARGET_OS_OSX // [macOS
279- - (void )viewDidMoveToWindow
280- {
281- [super viewDidMoveToWindow ];
282-
283- NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter ];
284- if (self.window == nil ) {
285- // Unregister scrollview's clipview bounds change notifications
286- [defaultCenter removeObserver: self
287- name: NSViewBoundsDidChangeNotification
288- object: _scrollView.contentView];
289- } else {
290- // Register for scrollview's clipview bounds change notifications so we can track scrolling
291- [defaultCenter addObserver: self
292- selector: @selector (scrollViewDocumentViewBoundsDidChange: )
293- name: NSViewBoundsDidChangeNotification
294- object: _scrollView.contentView]; // NSClipView
295- }
296- }
297-
298279- (void )setContentInset : (UIEdgeInsets)contentInset
299280{
300281 if (UIEdgeInsetsEqualToEdgeInsets (contentInset, _contentInset)) {
@@ -827,9 +808,25 @@ - (void)didMoveToWindow
827808 [super didMoveToWindow ];
828809#else // [macOS
829810- (void )viewDidMoveToWindow // [macOS]
811+ #endif // [macOS]
830812{
831813 [super viewDidMoveToWindow ];
832- #endif // [macOS]
814+
815+ #if TARGET_OS_OSX // [macOS
816+ NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter ];
817+ if (self.window == nil ) {
818+ // Unregister scrollview's clipview bounds change notifications
819+ [defaultCenter removeObserver: self
820+ name: NSViewBoundsDidChangeNotification
821+ object: _scrollView.contentView];
822+ } else {
823+ // Register for scrollview's clipview bounds change notifications so we can track scrolling
824+ [defaultCenter addObserver: self
825+ selector: @selector (scrollViewDocumentViewBoundsDidChange: )
826+ name: NSViewBoundsDidChangeNotification
827+ object: _scrollView.contentView]; // NSClipView
828+ }
829+ #endif // macOS]
833830
834831 if (!self.window ) {
835832 // The view is being removed, ensure that the scroll end event is dispatched
0 commit comments