macos 如何设置 NSScrollView 的内容大小?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9768995/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:59:32  来源:igfitidea点击:

How to set the content size of NSScrollView?

macosnsscrollview

提问by Developer

I am new to Mac OSX Programming. I have created on iOS apps in which I can set The content size of UISCrollView by using contentSize property. But there is no such property I found for Mac Apps. How it can be done and how can I enable the scrolling in Mac App. I looked on to the other questions on Stackoverflow but I didn't find anything relevant. Thanks-

我是 Mac OSX 编程的新手。我在 iOS 应用程序上创建了,我可以在其中使用 contentSize 属性设置 UISCrollView 的内容大小。但是我没有为 Mac Apps 找到这样的属性。如何完成以及如何在 Mac App 中启用滚动。我查看了 Stackoverflow 上的其他问题,但没有找到任何相关内容。谢谢-

回答by Sohaib

NSScrollView has documentView attached to it. You can change the content size by updating the frame of documentView.

NSScrollView 附加了 documentView。您可以通过更新 documentView 的框架来更改内容大小。

[scrollView.documentView setFrame: NSMakeRect(0,0,new_width, new_height) ];

[scrollView.documentView setFrame: NSMakeRect(0,0,new_width, new_height) ];