non*_*ive 39 macos cocoa objective-c uiscrollview nsscrollview
我正在制作一个需要知道用户何时滚动的Mac应用程序NSScrollView,但是,我找不到任何类似的方法UIScrollView,它具有以下委托方法:
– scrollViewDidScroll:
– scrollViewWillBeginDragging:
– scrollViewDidEndDragging:willDecelerate:
– scrollViewShouldScrollToTop:
– scrollViewDidScrollToTop:
– scrollViewWillBeginDecelerating:
– scrollViewDidEndDecelerating:
Run Code Online (Sandbox Code Playgroud)
我可以为App Kit使用类似的委托方法吗?提前致谢.
凯.
小智 68
您可以通过监视滚动视图的内容视图的边界来监视滚动视图的更改.首先设置内容视图以发布其更改
[contentView setPostsBoundsChangedNotifications:YES];
Run Code Online (Sandbox Code Playgroud)
然后注册为这些通知的观察者
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(boundsDidChange:) name:NSViewBoundsDidChangeNotification object:contentView];
Run Code Online (Sandbox Code Playgroud)
wol*_*fan 11
Swift 4 更新:
scrollView.contentView.postsBoundsChangedNotifications
Run Code Online (Sandbox Code Playgroud)
另外,调用的是:
NotificationCenter.default.addObserver(self,
selector: #selector(boundsChange),
name: NSView.boundsDidChangeNotification,
object: scrollView.contentView)
Run Code Online (Sandbox Code Playgroud)
编辑:mac中的集合不继承自scrollview。正确更新
| 归档时间: |
|
| 查看次数: |
11793 次 |
| 最近记录: |