我试图将UILabel与在类中创建的IBOutlet链接起来。
我的应用程序崩溃与以下错误。
这是什么意思?
我该怎么解决呢?
***终止应用由于未捕获异常'NSUnknownKeyException',原因:'[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]:这个类不是键值编码兼容的键XXX。'
我试图将UILabel与在类中创建的IBOutlet链接起来。
我的应用程序崩溃与以下错误。
这是什么意思?
我该怎么解决呢?
***终止应用由于未捕获异常'NSUnknownKeyException',原因:'[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]:这个类不是键值编码兼容的键XXX。'
当前回答
这个错误是另一回事!
这是我如何解决它。我使用xcode版本6.1.1和使用swift。每次我的应用程序尝试执行segue跳转到下一个屏幕时,我都得到这个错误。这是我所做的。
Checked that the button was connected to the right action.(This wasn't the problem, but still good to check) Check that the button does not have any additional actions or outlets that you may have created by mistake. (This wasn't the problem, but still good to check) Check the logs and make sure that all the buttons in the NEXT SCREEN have the correct actions, and if there are any segues, make sure that they have a unique identifier. (This was the problem) One of the segues did not have a unique identifier One of the buttons had an action and two outlets that I created by mistake. Delete any additional outlets and make sure that you the segues to the next screen have unique identifiers.
欢呼,
其他回答
我收到了完全相同的错误信息,感谢http://www.idev101.com的Kira,我能够解决这个挑战。我是在谷歌搜索了所有这些线索后才找到她的网站的。我现在在这里发布下一个来到StackOverFlow的帖子,并且有同样的挑战,因为那个人最有可能通过谷歌来到这个线程。
我意识到,我错了:
UIViewController *deviceViewController = [[UIViewController alloc] initWithNibName:@"DeviceViewController" bundle:nil];
而不是这样:
DeviceViewController *deviceViewController = [[DeviceViewController alloc] initWithNibName:@"DeviceViewController" bundle:nil];
在哪里
DeviceViewController
我的类名也被称为
DeviceViewController.h
DeviceViewController.m
你必须得
"import DeviceViewController.h"
在您的实现中(。m文件),你想调用例如另一个UIViewController。
如果我只是说明了像我这样的初学者,我绝对不会感到抱歉,因为这与问题并不完全相关,但我已经连续搜索了4个小时(?!?)来寻找这些错误消息的答案。如果我能把这个留给一两个人,那就太好了:)
PS:对于那些对如何继续加载其他UIViewController的代码感兴趣的人:
[self presentViewController:deviceViewController animated:YES completion:nil];
选择器对象是否未连接?
哈哈,54个答案,没有一个是我的解决方案。谈论一个常见的错误。
在我的情况下,这是因为我在我的VC上有一个选择器对象,并没有为它设置一个出口和动作。
当我只是想看看布局如何时,我经常不连接按钮等。但对于采摘者来说,你似乎做不到这一点。
我在一个有两个目标(有自己的MainWindow XIB)的项目中遇到了类似的问题。对我来说,导致这个错误的根本问题是UIViewController类没有包含在第二个项目的资源列表中。例如,界面构建器允许我在主窗口中指定它。Xib,但在运行时系统无法定位类。
例如,cmd-点击有问题的UIViewController类,并仔细检查它是否包含在“Targets”选项卡中。
我在用沙玛林。IOS来创建自定义nib。最后我找到了根本原因,去Xcode,选择nib文件,在接口构建器中,选择UIView类,选择连接检查器,并删除默认的出口,如下所示。
我的麻烦的原因,是我复制了一个故事板文件(Xcode之外,如果我没有记错),然后所有视图控制器在复制的文件有相同的对象id在原始文件。补救办法是复制粘贴视图控制器,然后它们将获得一个新的object-ID。您可以在Identity Inspector中看到object-ID。