简体   繁体   English

如何将NIB文件与自定义NSView类关联?

[英]How do you associate a NIB file with a custom NSView class?

I have a custom myCustomNSView class. 我有一个自定义的myCustomNSView类。 I have also created a nib file for it. 我还为此创建了一个nib文件。 How do i link the two together so that i can instantiate the myCustomNSView class and add it as a subview of some other view? 如何将两者链接在一起,以便可以实例化myCustomNSView类并将其添加为其他视图的子视图? The answer provided by this question is perfect except, I am working with OSX not iOS. 所提供的答案这个问题是除了,我用OSX工作不完美的iOS。

Looking at Apple's documentation i see the following: 查看苹果的文档,我看到以下内容:

在此处输入图片说明

How can this be done for OSX? 对于OSX,该如何完成?

If you look into the header NSNib.h , you will see that the new official method is: 如果查看标题NSNib.h ,您将看到新的正式方法是:

- (BOOL)instantiateWithOwner:(id)owner topLevelObjects:(NSArray **)topLevelObjects 

It is the Very same as for UIKit. 与UIKit非常相似。 I have no idea, why it is so poorly documented. 我不知道为什么它记录的这么少。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM