我试图将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.
欢呼,
其他回答
当我的视图控制器最初有一个.xib文件时,这种情况发生在我身上,但现在是以编程方式创建的。
尽管我已经从这个项目中删除了.xib文件。用户的iPhone/iPad可能包含这个视图控制器的.xib文件。
尝试加载.xib文件通常会导致以下崩溃:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x18afe0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key welcomeLabel.'
以编程方式创建时的解决方案可能是这样的:
-(void)loadView {
// Ensure that we don't load an .xib file for this viewcontroller
self.view = [UIView new];
}
如果它只是一个iPhone应用,而不是一个通用的应用,请确保以下字段为空:
目标>摘要> iPhone/iPod部署信息>主界面
如果你在这里指定了xib,它会崩溃。
此错误指示已经连接的接口构建器对象在其所有者的源(文件的所有者)中被删除/重命名。
如果你看到一个感叹号,请在界面构建器中控制单击文件的所有者,你需要修复它。
在下图中,你可以看到“aRemovedView”在其右侧有一个感叹号,这是因为我删除了IBOutlet视图对象,而它已经在IB中连接。
这将给出以下错误: 终止应用程序由于未捕获异常'NSUnknownKeyException',原因:'[setValue:forUndefinedKey:]:这个类不是键值编码兼容键aRemovedView。'
我也有同样的问题,原因是在接口生成器中指定了一个模块(而不是让它为空)。所以,当我使用一个不同于我设置的模块时,应用程序会崩溃:S…希望这能帮助别人,因为我的问题不是由于损坏或过时的出口!
我只是在我的重复项目中有这个问题,并通过检查2个地方来解决:
1-确保你有。m文件在列表->项目-构建阶段-编译源代码 2-在那之后,去接口构建器(可能这是一个错误只发生在IB),并断开所有属性,标签,图像等…然后重新链接所有。我已经意识到我已经删除了一个属性,但它仍然在IB中链接。
希望这对一些人有用。