为什么 Xcode 7.2 崩溃“无法实例化名为 IBNSLayoutConstraint 的类”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34202672/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:18:19  来源:igfitidea点击:

why Xcode 7.2 crash 'Could not instantiate class named IBNSLayoutConstraint'?

xcodexcode7xcode7.1xcode7.2

提问by ali

*** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named IBNSLayoutConstraint'

*** 由于未捕获的异常“NSInvalidUnarchiveOperationException”而终止应用程序,原因:“无法实例化名为 IBNSLayoutConstraint 的类”

I just update Xcode to 7.2 then i start to check is everything alright. but I have this error and it crashes. I dig this problem, everybody said that "Make sure you don't have any constraints installed for views that aren't installed." but I don't have any uninstalled constrains. and I don't have any NSLayoutConstraint outlets. Thanks a lot.

我只是将 Xcode 更新到 7.2,然后我开始检查一切是否正常。但我有这个错误,它崩溃了。我挖了这个问题,每个人都说“确保没有为未安装的视图安装任何约束。” 但我没有任何卸载的约束。而且我没有任何 NSLayoutConstraint 插座。非常感谢。

采纳答案by eakgul

You probably using InterfaceBuilder Storyboardfor localization. You should also consider them and remove inactive constraits inside them or use Localizable Stringsfor localization.

您可能使用InterfaceBuilder Storyboard进行本地化。您还应该考虑它们并删除它们内部的非活动约束或使用Localizable Strings进行本地化。

You can also check thisanswer.

您也可以查看答案。

Storyyboard localization section

故事板本地化部分

回答by Arvind Kumar

Select Storyboard Disable Size class resolve my problem. Hope this will help you! Thanks After build your project you can again enable size class.

选择 Storyboard Disable Size 类解决我的问题。希望能帮到你!谢谢 构建您的项目后,您可以再次启用大小类。

enter image description here

在此处输入图片说明

回答by Evgeny Mikhaylov

In my case I had "padView" that was not installed in any/any size class and was installed in regular/regular size class, but it's subviews were installed in all size classes.

在我的情况下,我的“padView”没有安装在任何/任何尺寸类中,而是安装在常规/常规尺寸类中,但它的子视图安装在所有尺寸类中。

enter image description here

在此处输入图片说明

"PadView" settings:

“PadView”设置:

enter image description here

在此处输入图片说明

"PadView" subviews settings:

“PadView”子视图设置:

enter image description here

在此处输入图片说明

When I changed "PadView" subviews installation settings to the same as "PadView" settings my problem was resolved.

当我将“PadView”子视图安装设置更改为与“PadView”设置相同时,我的问题就解决了。

enter image description here

在此处输入图片说明

回答by Kayron Cabral

I had a view deactivated (not installed) in my main view in IB. I deleted it and also deleted all the constraints without reference to IB. And worked for me.

我在 IB 的主视图中有一个视图被停用(未安装)。我删除了它,也删除了所有约束,没有参考IB。并对我来说有效。

View deactivated

查看已停用

Attributes inspector

Attributes inspector

回答by vedrano

I have an app that sets custom size classes for iPad so app recognizes Portrait and Landscape orientations as Regular/Compact and Compact/Regular traits.

我有一个为 iPad 设置自定义尺寸类的应用程序,因此应用程序将纵向和横向方向识别为常规/紧凑和紧凑/常规特征。

So, when I had one view installed only as both R/C Installed and C/R Installed, I got crash: 'Could not instantiate class named IBNSLayoutConstraint' when I upgraded to 7.2 final.

因此,当我仅将一个视图安装为 R/C Installed 和 C/R Installed 时,我会崩溃:当我升级到 7.2 final 时,“无法实例化名为 IBNSLayoutConstraint 的类”。

Fix is very simple: to add view install for Any/Any: "Installed"

修复非常简单:为 Any/Any 添加视图安装:“已安装”

By comparing Storyboard source it appears that this line was removed after fixing:

通过比较 Storyboard 源代码,似乎在修复后删除了这一行:

// y4d-LA-PwQ is view specific ID

// y4d-LA-PwQ 是视图特定的 ID

回答by ?zgür

It is easy to solve without applying the hackery mentioned in the above answer. Switch your IB to any/any and look through the subviews of each topview. If you find a super view that is not installed and subview of it installed, disable this installed subview in any/any so that the super view and the subviews will have same status of installation.

不应用上述答案中提到的hackery,很容易解决。将您的 IB 切换到任意/任意并查看每个俯视图的子视图。如果您发现一个未安装的超级视图并安装了它的子视图,请在 any/any 中禁用此已安装的子视图,以便超级视图和子视图具有相同的安装状态。

回答by D.p

Try checking "Use Size Classes":

尝试检查“使用尺寸等级”:

enter image description here

enter image description here

回答by Steven

I did have a similar issue in where I received a "Could not instantiate class named IBNSLayoutContraint" error when one of my apps loaded my XIBs. It ended up being one of my contraints had a check mark on it's properties. It was something like "Remove from Build". I unchecked it and resolved my error. I don't think this is the solution to your problem.

我确实有一个类似的问题,当我的一个应用程序加载我的 XIB 时,我收到了“无法实例化名为 IBNSLayoutContraint 的类”错误。它最终成为我的约束之一,它的属性上有一个复选标记。它类似于“从构建中删除”。我取消选中它并解决了我的错误。我不认为这可以解决您的问题。