简体   繁体   English

从NIB加载UIView

[英]Loading UIView from NIB

I have a view controller V which is part of a story board. 我有一个故事控制器的视图控制器V。 On its viewDidLoad method it attempts to load a few views from a NIB (not a storyboard). 在其viewDidLoad方法上,它尝试从NIB(而不是情节提要)加载一些视图。 The idea is to "assemble" some of the view using these "subviews". 这个想法是使用这些“子视图”“组合”一些视图。

However, when I try to load a view like this: 但是,当我尝试加载这样的视图时:

NSArray *bundle = [[NSBundle mainBundle] loadNibNamed:@"x"
                                                owner:self options:nil];

I'm getting an exception saying 'this class is not key value coding-compliant for the key yyy.' 我收到一个例外消息,说“此类不符合键yyy的键值编码标准。”

This is because the view in the NIB has a custom view controller, which has an outlet to a component in this view, which is connected in the NIB properly. 这是因为NIB中的视图具有自定义视图控制器,该视图控制器具有该视图中组件的出口,该组件已在NIB中正确连接。

What am I doing wrong here? 我在这里做错了什么?

right click on your fileOwner viewController in interface builder and then delete yyy outlet, you have an outlet connection, which is not existed or deleted 右键单击界面生成器中的fileOwner viewController ,然后删除yyy插座,您有一个插座连接,该连接不存在或删除
Update screenShote added 更新画面已添加
xoced界面构建器

Look at this screenshot the button has 2 outlets, but yyyy is not existed in the viewController. 看这张截图,按钮有2个插座,但是yyyy在viewController中不存在。 you should delete this outlet 您应该删除此插座
在此处输入图片说明

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

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