Interface Builder 插件加载时图像检查器属性问题
我创建了一个显示图像的自定义 NSView。
我在检查器视图中创建了一个属性,并绑定到文件的所有者。
在运行时图像更改中一切正常。 但是当我保存和加载 xib 文件时没有加载任何内容。
这是简化的代码:
IBDocument *document = [IBDocument documentForObject:self];
[self->defaultImage release];
self->defaultImage = [document documentImageNamed:aImage];
[self->defaultImage setName:aImage];
[self->defaultImage retain];
[document documentImageNamed:aImage]
在运行时返回一个 NSImage,但是当从文件加载时它返回 nil
尽管 NSImageWell 在运行时和以下情况下工作正常从编码器初始化。
我缺少什么?
谢谢。
i have created a custom NSView that displays an image.
i have created a property in Inspector view with binding to File's Owner.
Everything works fine in runtime image changing.
But nothing is loaded when i save and load xib file.
here is the simplified code:
IBDocument *document = [IBDocument documentForObject:self];
[self->defaultImage release];
self->defaultImage = [document documentImageNamed:aImage];
[self->defaultImage setName:aImage];
[self->defaultImage retain];
The [document documentImageNamed:aImage]
returns an NSImage in runtime, but when loading from file it return nil
though the NSImageWell works fine in runtime and when initialized from coder.
What i'm missing?
Thans.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须为自定义对象实现 NSCoding 协议。
http://开发人员。 apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Protocols/NSCoding_Protocol/Reference/Reference.html
You must implement NSCoding protocol for you custom object.
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Protocols/NSCoding_Protocol/Reference/Reference.html