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

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

问题描述

我对xcode很新...一个应用程序(简单的计算器)工作非常好(在模拟器和设备上)。
当我在目标摘要选项中设置主界面时,启动模拟器时出现以下错误:

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] * 终止app $ due
到未捕获的异常'NSUnknownKeyException' ,

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

原因:
' [< UIApplication 0x6a14650> setValue:forUndefinedKey:] :这个类是
,不是密钥值编码兼容的密钥calculatorScreen。'

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 0x12dcdea 0x12467f1 0x53526e
0x536eb7 0x313ce1 0x313ff8 0x31317f 0x322183 0x322c38 0x316634
0x27fcef5 0x12af195 0x1213ff2 0x12128da 0x1211d84 0x1211c9b 0x312c65
0x314626 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崩溃[27494:f803] * 由于未被捕获的
异常'NSUnknownKeyException'而终止应用程序,原因:

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

' [< UIApplication 0x6a6f4b0> 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 0x94bd50
0x23371a 0x13c8dea 0x13327f1 0x23226e 0x233eb7 0x10ce1 0x10ff8 0x1017f
0x1f183 0x1fc38 0x13634 0x12b1ef5 0x139b195 0x12ffff2 0x12fe8da
0x12fdd84 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

是否有问题的解决方案?

is there a solution for the problem?

推荐答案

如果您的笔尖(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属性设置为ViewContro ller.nib。这是一个问题,因为唯一应该用作主界面的笔尖应该包含UIWindows,并且该笔尖中的文件所有者应该设置为AppDelegate。应该将nib中的UIWindow链接到文件所有者(AppDelegate)窗口属性。因为您使用没有运行时查找的特征的nib设置它,它会给您出现此错误。

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天全站免登陆