如何在 Storyboard 中使用现有 NSView 设置 NSScrollview 的内容 XCode

How to set the content of a NSScrollview with an existing NSView in the storyboard XCode

我有一个包含 NSScrollView 的 NSViewController,我想将该 NSScrollView 的内容添加为 Storyboard 中定义的 NSView,但我无法以任何方式做到这一点。

我不想以编程方式创建内容,我更愿意在故事板上定义它,因为内容是静态的。

@IBOutlet weak var scrollView: NSScrollView!
scrollView.addSubview(//What to add here?)

这个问题类似于iOS编程How to use UIScrollView in Storyboard

通常在处理 NSScrollViews 时,使用约束总是有帮助的(特别是如果您的应用程序对于不同版本的 iPhone/iPad 是通用的)。你试过和他们一起工作吗?

答案是使用 xib 文件。