objective-c - 滚动 NSScrollView 时的回调?

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

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

我可以为 App Kit 提供类似的委托(delegate)方法吗?提前致谢。

启。

最佳答案

您可以通过监视其内容 View 的边界来监视 ScrollView 的更改。首先将内容 View 设置为使用

发布其更改
[contentView setPostsBoundsChangedNotifications:YES];

然后使用

注册为这些通知的观察者
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(boundsDidChange:) name:NSViewBoundsDidChangeNotification object:contentView]; 

https://stackoverflow.com/questions/5169355/

相关文章:

iphone - 如何在我的 Objective-C 源代码中转义 Unicode 字符?

ios - 呈现模态视图 Controller 的延迟

iphone - 更改 UIAlertView 的背景颜色?

iphone - 如何以编程方式创建 UIScrollView?

iphone - Objective-C 中的实例变量是否默认设置为 nil?

ios - swift 中的@property/@synthesize 等价物

ios - 静态和动态单元格的 UITableView 混合?

ios - 仅在 Testflight 构建时应用程序崩溃

iphone - NSDateFormatter,我做错了什么还是这是一个错误?

objective-c - 在 Objective-C 中定义协议(protocol)的类别?