NSScrollView 框架和翻转的 documentView

发布于 2024-08-30 21:57:52 字数 419 浏览 4 评论 0原文

我的 NSScrollView 有问题,它没有按我想要的方式显示。 是的,我知道网上有很多关于它的帖子,我需要重写 isFlipped,以便使其在我的 NSView 子类中返回 YES。

好的,完成了,所以现在,我的scrollView从上到下滚动,而不是像重写isFlipped之前那样以相反的方式滚动。

但是,这是第二部分,我真正的问题,我在网上没有找到任何答案,如果一切都翻转了,我到底应该如何编码,或者在界面生成器中创建我的视图?如果我把一些东西放在顶部,它就会显示在底部......你有什么魔术来处理这个问题吗?

我的最后一个问题是 NSScrollView 框架。在设置滚动视图的文档视图之前,一切都很好,滚动视图显示在我选择的位置,但是,当我设置文档视图时,滚动视图框架看起来更大,所以我必须调整它的大小......。这是正常行为吗?

非常感谢。

I have problems with NSScrollView, It is not displayed the way I want.
Yes I know there is a lot of post about it around the web, I need to override the isFlipped, in order to make it return YES, in my NSView subclass.

Ok, it's done, so now, my scrollView scroll from top to bottom, and not in the reverse way, as it was before overriding isFlipped.

But, this is the second part, my real problem, which I didn't found any answer on the web, how the hell I'm supposed to code, or create my view in interface builder, if everything is flipped? If I put something at the top, it is displayed a the bottom… do you have any magic trick to handle that?

And my last problem, is the NSScrollView frame. before setting the documentView of my scroll view, everything is fine, the scrollView is displayed at the place I choose, but, when I set the document view, it looks like the scrollview frame looks bigger, so I have to resize it…. is this a normal behavior?

Thank you very much.

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

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

发布评论

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

评论(2

花桑 2024-09-06 21:57:52

答案通常是创建一个 NSClipView 子类,该子类从 isFlipped 的重写返回 YES:

然后在 IB 中,将滚动视图的内容视图(剪辑视图)设置为您的子类。

The answer is usually to create an NSClipView subclass that returns YES from an override of isFlipped:

Then in IB, set the scroll view's content view (clip view) to your subclass.

全部不再 2024-09-06 21:57:52

翻转仅将其坐标系应用于该确切视图,而不是整个视图层次结构中的所有内容。因此,无论您直接放入翻转的内容视图中,都需要知道它已翻转,但其他任何东西都不会。

如果您不希望它以这种方式工作,请不要要求将其翻转!没有规则规定 NSScrollView 的文档视图必须翻转,对于具有可变高度内容的任何内容从上到下布局是很常见的,这在翻转视图。如果您正在做的布局最适合底部锚定,那么无论如何,保持它不翻转,无论什么是最简单的。 (无论如何,Interface Builder 中的任何内容都应该没问题……您是否真的看到了这个问题,或者您只是猜测它可能会发生?我从未见过这个问题……)

设置文档视图不应更改 NSScrollView 的大小。除此之外,你可能还有其他事情发生......

Being flipped only applies its coordinate system to that exact view, not everything down the whole view hierarchy. So whatever you're putting directly into your flipped content view needs to be aware that it's flipped, but nothing else does.

And if you don't want it to work that way, just don't ask for it to be flipped! There's no rule that says that the document view of an NSScrollView has to be flipped, it's just very common for anything with variable-height content to be laid out top to bottom, which is easiest to do in a flipped view. If the layout you're doing works best as bottom-anchored, by all means, keep it unflipped, whatever's easiest. (And anything in Interface Builder should be fine anyway…did you actually see this problem, or are you just speculating that it might happen? I've never seen this issue…)

Setting the document view shouldn't change the size of the NSScrollView. You may have something else going on besides just that…

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