iOS开发- setValue:forUndefinedKey:]: this class is not key value coding-comp

来源:互联网 发布:网络推广的计划方案 编辑:程序博客网 时间:2024/06/06 02:29

我们有时候在 使用 storyboard,会遇到以下的情况

运行程序时崩溃:控制台打印:

'NSUnknownKeyException', reason: '[<ViewController 0x7fa610e91180> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key button.'


这是一个新手容易犯的错误,是由于  在 storyboard拖拽到 controller类之后,修改了,IBOut

@interfaceViewController ()@property (strong,nonatomic)IBOutletUIButton *button222;  //通过storyboard拖拽时生成button,但是自己后来修改为button222,导致了崩溃@end


解决办法:找到 相应的控件,(右键查看,outlet)删除 (出现黄色感叹号的[一般] )对应的控件的  OutLet即可,

如果没有找到该控件,可以直接查看  ViewController的  输出链接(inspector 最后一个)


原文地址:http://blog.csdn.net/yangbingbinga

0 0
原创粉丝点击