gpt4 book ai didi

cocoa - NSImage 上的 NSScrollView 和 ScrollToPoint

转载 作者:行者123 更新时间:2023-12-03 16:58:36 26 4
gpt4 key购买 nike

我有一个 NSView 作为 NSScrollView 的 documentView。我还有一个 NSImageView 作为 NSView 的 subview 。图像动态改变大小,因此滚动条在不同时间变为事件/非事件状态。图像更改后,我想滚动到图像上的某个点。从 NSView 的 drawRect: 方法中,我调用 [[myScrollView contentView]scrollToPoint: myPoint];

滚动条更新并且图像按照我的意愿显示,但是一旦图像滚动,就会出现双图像或图像的部分内容被切断。任何帮助,将不胜感激。谢谢。

最佳答案

听起来您可能想在 Interface Builder 中或以编程方式关闭 NSScrollView 的“Copy On Scroll”行为选项。

来自Scroll View Programming Guide for Mac OS X: How Scrolling Works :

The NSClipView class provides low-level scrolling support through the scrollToPoint: method. This method translates the origin of the content view’s bounds rectangle and optimizes redisplay by copying as much of the rendered document view as remains visible, only asking the document view to draw newly exposed regions. This usually improves scrolling performance but may not always be appropriate. You can turn this behavior off using the NSClipView method setCopiesOnScroll: passing NO as the parameter. If you do leave copy-on-scroll active, be sure to scroll the document view programmatically using the NSView method scrollPoint: method rather than translateOriginToPoint:.

关于cocoa - NSImage 上的 NSScrollView 和 ScrollToPoint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10417899/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com