自身窗口内的 NSView

发布于 2024-08-17 09:21:44 字数 96 浏览 12 评论 0原文

我有基本的 *.xib 文件,其中有 NSView。

如何为此自定义视图使用另一个 nib 文件?什么是 NSViewController 以及我应该如何使用它?

I have basic *.xib file, which have NSView.

How can I use another nib files for this Custom View? What is NSViewController and how should I use it?

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

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

发布评论

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

评论(2

你好,陌生人 2024-08-24 09:21:44

通常,您创建一个新笔尖,选择“查看”作为笔尖模板。然后,在检查器的最后一个选项卡中选择文件的所有者并将其类设置为 NSViewController(或您自己的子类,在这种情况下,您可能必须首先将 nib 添加到您的 Xcode 项目)。然后将视图控制器的“视图”出口连接到视图。

你应该阅读Apple关于NSViewController的文档,它实际上是一个非常简单的类。但是,在开始绘图和编码之前,我建议您应该按照 MVC 术语仔细构建应用程序。如果你在设计阶段犯了错误,以后你将不得不重做很多工作。使用视图控制器并不总是合理的,它取决于应用程序的复杂性。

Generally, you create a new nib, selecting "View" as the nib template. Then you select the File's Owner and set its class to NSViewController (or your own subclass of it, in which case you may have to add the nib to your Xcode project first) in the last tab of the Inspector. Then you connect the view controller's "view" outlet to the view.

You should read Apple's docs on NSViewController, it's actually a very simple class. However, before you start drawing and coding I would suggest you should carefully structure your app in MVC terms. If you make a mistake in the design phase, you will have to redo a lot of your work later. Using view controllers is not always justified, it depends on the complexity of the app.

暖心男生 2024-08-24 09:21:44

NSViewController 顾名思义是一个控制器类,意味着它在完美的 MVC 环境中将视图连接到模型。

每个 ViewController 都绑定到一个视图,您可以使用代码或使用 Interface Builder 构建该视图。

如需更多帮助,我建议观看斯坦福大学 iPhone 编程课程,可在 Stanford iTunes(iTunes 链接),iPhone SDK 与 OSX SDK 共享同一个地下层,因此 ViewController 完全相同。

NSViewController as its name suggests is a Controller class, means it connects the View to the Model, in a perfect MVC environment.

Each ViewController is bound to one View, you can build that view in code or using the Interface Builder.

For more help, I would suggest to watch Stanford University iPhone programming course, it's available on Stanford iTunes (iTunes link), iPhone SDK share the same underground with the OSX SDK so it's exactly the same for ViewControllers.

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