您的位置:首页 > 移动开发 > Objective-C

iOS [<NSObject 0x170204110> setValue:forUndefineKey:]: this class is not key value coding-compliant

2016-01-05 20:54 811 查看
5th,Jan,2016

报错:uncaught exception 'NSUnknownKeyException',reason: '[<NSObject 0x170204110> setValue:forUndefineKey:]: this class is not key value coding-compliant for the key name.

今天在做一个聊天界面小demo,需要从xib文件加载UIView.一开始是新建的ViewController文件自带的xib文件,直接将.h文件中继承的类从UIViewController改成UIView。然后通过[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner: options 运行报错停在这一句上。

分析:使用[NSBundle mainBundle]loadNibNamed方式加载view文件时,仅适用于只有一个视图且没有任何其他交互绑定

解决方式:在connection inspector中,删除与view的关联,即可。

参考文献:


从Xib文件加载UIView的5种方式,xib加载uiview5种


iOS: setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key name.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: