NSCollectionView 捏合缩放
我试图通过实现 -(void)magnifyWithEvent:(NSEvent *)event
在 NSCollectionView 中进行捏缩放,但我不确定在这个方法中要做什么。我通过 [event magnification]
获取缩放量,现在我需要刷新集合视图内的项目。
我认为我可以将其保存在变量 zoomValue
中,并重写方法 - (NSCollectionViewItem *)newItemForRepresentedObject:(id)object
以调整每个集合的视图大小item (不过,我认为这不起作用。无论如何,我不知道如何触发集合视图的“刷新”)。
对此有什么想法吗? 谢谢。
I am trying to get pinch zoom in an NSCollectionView by implementing -(void)magnifyWithEvent:(NSEvent *)event
, but I'm not sure on what to do inside this method. I'm getting the amount of the zoom with [event magnification]
, and now I need to refresh the items inside the collection view.
I thought that I could save this in a variable zoomValue
, and override the method - (NSCollectionViewItem *)newItemForRepresentedObject:(id)object
in order to resize the view of each collection item (I think that this will not work, though. And anyway I don't know how to trigger the "refresh" of a collection view).
Any ideas about this?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在做类似的事情,但是是通过滑块而不是捏。
您只需要调用:
为了在拖动滑块期间实时调整大小,我必须调用一个私有方法 -[NSCollectionView _updateGridWithCurrentItemsIfNecessary],否则直到鼠标松开时调整大小才会发生。不确定你是否也会遇到同样的问题。
I'm doing something similar, but from a slider instead of a pinch.
You just need to call:
To get the resize to happen live during the drag of the slider, I had to call a private method -[NSCollectionView _updateGridWithCurrentItemsIfNecessary], otherwise the resize didn't happen until mouseup. Not sure if you'll have the same problem.