IKImageView 和滚动条

发布于 2024-08-21 02:18:27 字数 454 浏览 6 评论 0原文

我有一个 NSScrollView ,里面有一个 IKImageView 来显示图像。这似乎有效。

但是,如果我使窗口小于图像,滚动条将按其应有的方式显示,但图像的底部被锁定到窗口的底部,而不是图像的顶部被锁定到窗口的顶部。换句话说,当我从右下角调整窗口大小时,我希望图像不会在屏幕上移动。

我明白为什么会这样,因为在所有这些类中,原点都在左下角,而不是左上角。但是,它的行为仍然错误。如果您查看任何其他产品(包括预览版,我假设它是用其中一些库编写的),则图像/内容/任何内容都被锁定在顶部而不是底部。

我该怎么做?

我在 NSScrollView 和 IKImageView 中寻找方法。我考虑过捕获滚动条事件并根据需要手动向下或向上移动图像,但我还没有找到一种方法来做到这一点(将选择器设置为我在控制器中编写的方法?)无论如何,这看起来非常凌乱...

有一个简单的方法可以做到这一点吗?

谢谢。

I have an NSScrollView with an IKImageView inside to display images. This seems to work.

However, if I make the window smaller than the image, the scrollbars appear as they should, but the BOTTOM of the image is locked to the bottom of the window, instead of the top of the image being locked to the top of the window. In other words, I want the image to not move on the screen when I re-size the window from the bottom right.

I understand why this is, because in All of these classes, the origin is in the lower left, not the upper left. However, It's still behaving wrong. If you look at any other product (including Preview, which I assume is written with some of these libraries) the image/content/whatever, is locked to the top not the bottom.

How do I do this?

I've looked for methods in the NSScrollView and IKImageView. I've considered capturing the scroller events and manually moving the image down or up as appropriate, but I haven't seen a way to do this (Set the selector to a method I write in the controller?) and anyway, that seems very messy...

Is there an easy way to do this?

thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

几度春秋 2024-08-28 02:18:27

解决方案供以后参考:
创建一个仅包含一个重写方法的 IKImageView 子类:

-isFlipped()
{
   return YES;
}

如果我发现需要重新实现类中存在的rotate:(id)方法和setImage:(NSImage)方法,这个子类也将证明是有用的(在旋转的情况下,在 Apple 提供的演示中使用)但没有记录,因此不受官方支持......

Solution for future reference:
Make a subclass of IKImageView with only one over-ridden method:

-isFlipped()
{
   return YES;
}

This subclass will also prove useful if I find that I need to re-implement the rotate:(id) method and the setImage:(NSImage) method which exist in the class (and in the case of rotate are USED IN THE DEMO supplied by Apple) but not documented, and therefore not officially supported...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文