滚动NSScrollView时的回调? [英] Callbacks When an NSScrollView is Scrolled?

查看:106
本文介绍了滚动NSScrollView时的回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个Mac应用程序,该应用程序需要知道用户何时滚动NSScrollView,但是,找不到像UIScrollView这样的具有以下委托方法的任何方法:

I'm making a Mac app which needs to know when the user is scrolling the NSScrollView, however, I can't find any methods like UIScrollView, which has the following delegate methods:

– scrollViewDidScroll:
– scrollViewWillBeginDragging:
– scrollViewDidEndDragging:willDecelerate:
– scrollViewShouldScrollToTop:
– scrollViewDidScrollToTop:
– scrollViewWillBeginDecelerating:
– scrollViewDidEndDecelerating:

我可以为App Kit使用类似的委托方法吗?预先感谢.

Can I have the similar delegate methods for the App Kit? Thanks in advance.

开.

推荐答案

您可以通过监视滚动视图的内容视图的边界来监视滚动视图的更改.首先设置内容视图以使用

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];

然后使用

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

这篇关于滚动NSScrollView时的回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆