此类不符合键视图的键值编码 [英] this class is not key value coding-compliant for the key view

查看:31
本文介绍了此类不符合键视图的键值编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 xcode 很陌生……一个制作的应用程序(简单的计算器)工作得很好(在模拟器和设备上).当我在 Targetsummary 选项中设置主界面时,启动模拟器时出现以下错误:

i´m very new to xcode... a made an app (simple calculator) work´s pretty good (on simulator and device). When i set the main interface in the summary options from Target, i get the following error when starting the simulator:

2012-04-14 12:17:27.123 CalcTest[27550:f803] * 终止应用到期未捕获的异常NSUnknownKeyException",

2012-04-14 12:17:27.123 CalcTest[27550:f803] * Terminating app due to uncaught exception 'NSUnknownKeyException',

原因:'<代码>[setValue:forUndefinedKey:]: 这个类是键计算器屏幕不符合键值编码.'

reason: '[<UIApplication 0x6a14650> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key calculatorScreen.'

* 第一次抛出调用堆栈:(0x12db022 0x18f8cd6 0x12daee1 0xcc2022 0xc33f6b 0xc33edb 0xc4ed50 0x53671a 0x12dcdea67f5324x50x536eb7 0x313ce1 0x313ff8 0x31317f 0x322183 0x322c38 0x3166340x27fcef5 0x12af195 0x1213ff2 0x12128da 0x1211d84 0x1211c9b 0x312c650x314626 0x1bad 0x1b15 0x1) 终止调用抛出一个异常(lldb)

* First throw call stack: (0x12db022 0x18f8cd6 0x12daee1 0xcc2022 0xc33f6b 0xc33edb 0xc4ed50 0x53671a 0x12dcdea 0x12467f1 0x53526e 0x536eb7 0x313ce1 0x313ff8 0x31317f 0x322183 0x322c38 0x316634 0x27fcef5 0x12af195 0x1213ff2 0x12128da 0x1211d84 0x1211c9b 0x312c65 0x314626 0x1bad 0x1b15 0x1) terminate called throwing an exception(lldb)

为了找到问题,我开始了一个新的基于视图的项目.

to find the problem, i started a new view based project.

在模拟器上运行空的新项目-->有效,

Run the empty new project on the simulator -->works,

但是当我将主界面设置为ViewController时,在摘要中-->模拟器崩溃了

But when I set the main interface, to ViewController, in the summary -->the Simulator crash with

2012-04-14 12:11:17.492 crash[27494:f803] * 由于未捕获而终止应用异常 'NSUnknownKeyException',原因:

2012-04-14 12:11:17.492 crash[27494:f803] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason:

'[setValue:forUndefinedKey:]: 这个类是不符合键值编码的键视图.* 第一次抛出调用栈:

'[<UIApplication 0x6a6f4b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.' * First throw call stack:

(0x13c7022 0x1558cd6 0x13c6ee1 0x9bf022 0x930f6b 0x930edb 0x94bd500x23371a 0x13c8dea 0x13327f1 0x23226e 0x233eb7 0x10ce1 0x10ff8 0x1017f0x1f183 0x1fc38 0x13634 0x12b1ef5 0x139b195 0x12ffff2 0x12fe8da0x12fdd84 0x12fdc9b 0xfc65 0x11626 0x1d4d 0x1cb5) 终止调用抛出异常

(0x13c7022 0x1558cd6 0x13c6ee1 0x9bf022 0x930f6b 0x930edb 0x94bd50 0x23371a 0x13c8dea 0x13327f1 0x23226e 0x233eb7 0x10ce1 0x10ff8 0x1017f 0x1f183 0x1fc38 0x13634 0x12b1ef5 0x139b195 0x12ffff2 0x12fe8da 0x12fdd84 0x12fdc9b 0xfc65 0x11626 0x1d4d 0x1cb5) terminate called throwing an exception

问题有解决方案吗?

推荐答案

如果您的 nib(xib 文件)中有一个控件链接到视图控制器中的属性 (IBOutlet) 或方法 (IBAction),并且您已删除或重命名属性或方法,运行时无法找到它,因为它已重命名并因此崩溃.

If you have a control in your nib (xib file) that is linked to a property (IBOutlet) or method (IBAction) in your view controller, and you have either deleted or renamed the property or method, the runtime can't find it because it has been renamed and therefore crashes.

就您而言,您已将项目的 Main Interface 属性设置为 ViewController.nib.这是一个问题,因为应该用作主界面的唯一笔尖应该在其中包含 UIWindows,并且该笔尖中的文件所有者应该设置为 AppDelegate.笔尖中的 UIWindow 应链接到文件所有者 (AppDelegate) 的窗口属性.因为你用一个没有运行时正在寻找的特征的笔尖设置它,它会给你这个错误.

In your case, you have set the Main Interface property of the project to your ViewController.nib. This is a problem because the only nibs that should be used as Main Interface should have UIWindows in them and the File Owner in that nib should be set to the AppDelegate. The UIWindow in the nib should be linked to the File Owner's (AppDelegate) window property. Because you set that with a nib without the traits the runtime was looking for, it gives you this error.

解决方案是将主界面留空,因为您不必再​​手动设置 UIWindows.

The solution is to leave the Main Interface blank as you do not have to set up UIWindows manually anymore.

这篇关于此类不符合键视图的键值编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆