错误:因未捕获的异常'NSUnknownKeyException'而终止应用程序,原因:'[< UIApplication 0x6887a30>的setValue:forUndefinedKey:] [英] Error: Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x6887a30> setValue:forUndefinedKey:]

查看:83
本文介绍了错误:因未捕获的异常'NSUnknownKeyException'而终止应用程序,原因:'[< UIApplication 0x6887a30>的setValue:forUndefinedKey:]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

完整错误是:由于未捕获的异常'NSUnknownKeyException'而终止应用程序,原因:'[setValue:forUndefinedKey:]:此类不是密钥的密钥值编码兼容。

The full error is: Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key.

所以我一直在尝试其他人一直在说类似问题。我试图摆脱项目中对landscapeView的每一次提及,包括ViewController_iPhone.xib中FIle所有者中的Connections,然后我通过在超类ViewController中创建插座来开始新鲜事(因为我想使用landscapeView和portraitView for iPad另外)然后我将ViewController_iPhone.xib和ViewController_iPad.xib中的连接分别设置为名为Landscape的UIView,我仍然会收到此错误。

So I have been trying what other people have been saying with similar problems. I have tried getting rid of every mention of landscapeView in the project, including the Connections in the FIle's Owner in the ViewController_iPhone.xib and then I started fresh by making outlets in the super class ViewController (since I want to use landscapeView and portraitView for iPad also) then I set up connections in ViewController_iPhone.xib and ViewController_iPad.xib to the UIView named Landscape in each respectively, and I still get this error.

我只是从应用程序开发开始,所以我正在尝试为支持iPhone和iPad上所有方向的应用程序制作模板。感谢您的帮助

I'm just starting out in app development so I'm trying to make a template for an app that is supportive of all orientations on both iPhone and iPad. Thanks for any help

编辑:这是我所有应用代表h和m以及main.m的链接:我得到的应用程序应该有一个根视图控制器在应用程序启动错误结束

Here is a link to all my app delegate h and m and main.m : I am getting the Applications are expected to have a root view controller at the end of application launch error

编辑2:所以我也尝试将landscapeView作为ViewController的一个属性,我在ViewController.m中创建了一个setter方法但是它仍然有同样的问题。

EDIT 2: So I also tried to make landscapeView a property of ViewController and I made a setter method in ViewController.m but it still has the same problem.

推荐答案

我发现这个错误发生的最常见的地方是当你实例化一个视图时来自一个不是xib所有者的类中的xib。

I've found the most common place this error happens is when you instantiate a view from a xib from within a class that is not the xib's owner.

我的意思是你可能会调用类似的东西:

What I mean by this is you might be calling something similar to this:

[[NSBundle mainBundle] loadNibNamed:@"MyView" owner:self options:nil];

您正在更改所有者,所以你必须确保 self 引用的类具有MyView所需的所有IBOutlet属性。通常这是在Interface Builder中完成的,但在这种情况下,您将以编程方式设置所有者,这意味着您无法在IB中建立连接。当IBOutlets不存在时,应用程序尝试建立这些连接并失败,给出您看到的错误。

You're changing the owner, so you have to be sure that the class that self refers to has all the IBOutlet properties needed by "MyView". Usually this is done in Interface Builder, but in this case you're setting your owner programmatically, which means you can't make the connections in IB. When the IBOutlets aren't there, the app tries to make those connections and fails, giving the error you see.

我的建议(不知道任何超过您的信息)到目前为止给出的是检查你是否在没有正确的IBOutlets的情况下进行了此次通话。

My advice (without knowing any more info than you've given so far) is to check to see if you've made this call without having the proper IBOutlets.

这篇关于错误:因未捕获的异常'NSUnknownKeyException'而终止应用程序,原因:'[< UIApplication 0x6887a30>的setValue:forUndefinedKey:]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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