Ios ';无法在descriptionForLayoutAttribute\u layoutItem\u系数中创建描述。有些东西是零';

Ios ';无法在descriptionForLayoutAttribute\u layoutItem\u系数中创建描述。有些东西是零';,ios,objective-c,xcode,autolayout,Ios,Objective C,Xcode,Autolayout,首先,我得到了3个不同的UIView来替换iPad故事板上Split view Controller中的细节视图 它在iOS8 iPad上运行良好。但当我加载一个细节视图时,应用程序在iOS7和iOS6模拟器中运行时崩溃 我只是假设这是因为我的故事板上的自动布局 有人知道怎么修吗 2014-09-25 04:15:19.705 PSTappsperance[48327:60b] Pad AppDelegate ######## 2014-09-25 04:15:27.869 PSTappsper

首先,我得到了3个不同的UIView来替换iPad故事板上Split view Controller中的细节视图

它在iOS8 iPad上运行良好。但当我加载一个细节视图时,应用程序在iOS7和iOS6模拟器中运行时崩溃

我只是假设这是因为我的故事板上的自动布局

有人知道怎么修吗

2014-09-25 04:15:19.705 PSTappsperance[48327:60b] Pad AppDelegate ########
2014-09-25 04:15:27.869 PSTappsperance[48327:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to create description in descriptionForLayoutAttribute_layoutItem_coefficient. Something is nil'
*** First throw call stack:
(
0   CoreFoundation                      0x0000000110a5c495 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x00000001107af99e objc_exception_throw + 43
2   CoreFoundation                      0x0000000110a5c2ad +[NSException raise:format:] + 205
3   Foundation                          0x00000001104ec548 descriptionForLayoutAttribute_layoutItem_coefficient + 145
4   Foundation                          0x00000001104ec3bc -[NSLayoutConstraint equationDescription] + 216
5   Foundation                          0x00000001104ec831 -[NSLayoutConstraint description] + 297
6   CoreFoundation                      0x0000000110a1d1b9 -[NSArray descriptionWithLocale:indent:] + 345
7   Foundation                          0x000000011037e14e _NSDescriptionWithLocaleFunc + 64
8   CoreFoundation                      0x00000001109e1244 __CFStringAppendFormatCore + 7252
9   CoreFoundation                      0x0000000110a1f913 _CFStringCreateWithFormatAndArgumentsAux + 115
10  CoreFoundation                      0x0000000110a7fa5b _CFLogvEx + 123
11  Foundation                          0x00000001103ae276 NSLogv + 79
12  Foundation                          0x00000001103ae20a NSLog + 148
13  UIKit                               0x000000010f927097 -[UIView(UIConstraintBasedLayout_EngineDelegate) engine:willBreakConstraint:dueToMutuallyExclusiveConstraints:] + 62
14  Foundation                          0x00000001104e32ac -[NSISEngine handleUnsatisfiableRowWithHead:body:usingInfeasibilityHandlingBehavior:mutuallyExclusiveConstraints:] + 521
15  Foundation                          0x00000001104e49b1 -[NSISEngine tryUsingArtificialVariableToAddConstraintWithMarker:rowBody:usingInfeasibilityHandlingBehavior:mutuallyExclusiveConstraints:] + 353
16  Foundation                          0x000000011039c26b -[NSISEngine tryToAddConstraintWithMarker:expression:integralizationAdjustment:mutuallyExclusiveConstraints:] + 663
17  Foundation                          0x00000001104ed180 -[NSLayoutConstraint _addLoweredExpression:toEngine:integralizationAdjustment:lastLoweredConstantWasRounded:mutuallyExclusiveConstraints:] + 275
18  Foundation                          0x00000001103981b0 -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 204
19  UIKit                               0x000000010f923f41 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 413
20  Foundation                          0x00000001104e529a -[NSISEngine withBehaviors:performModifications:] + 119
21  UIKit                               0x000000010f923d7d __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 401
22  UIKit                               0x000000010f923bc3 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
23  UIKit                               0x000000010f923e57 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 179
24  Foundation                          0x00000001104e529a -[NSISEngine withBehaviors:performModifications:] + 119
25  UIKit                               0x000000010f923d7d __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 401
26  UIKit                               0x000000010f923bc3 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
27  UIKit                               0x000000010f3ab975 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 95
28  Foundation                          0x00000001104e529a -[NSISEngine withBehaviors:performModifications:] + 119
29  UIKit                               0x000000010f3ab889 -[UIView(Hierarchy) _postMovedFromSuperview:] + 321
30  UIKit                               0x000000010f3b52ac -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1508
31  UIKit                               0x000000010f632778 -[UINavigationTransitionView transition:fromView:toView:] + 454
32  UIKit                               0x000000010f6325b0 -[UINavigationTransitionView transition:toView:] + 25
33  UIKit                               0x000000010f46f4d7 -[UINavigationController _startTransition:fromViewController:toViewController:] + 2893
34  UIKit                               0x000000010f46f787 -[UINavigationController _startDeferredTransitionIfNeeded:] + 547
35  UIKit                               0x000000010f470238 -[UINavigationController __viewWillLayoutSubviews] + 43
36  UIKit                               0x000000010f58a895 -[UILayoutContainerView layoutSubviews] + 202
37  UIKit                               0x000000010f3b7993 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 354
38  QuartzCore                          0x000000011427c802 -[CALayer layoutSublayers] + 151
39  QuartzCore                          0x0000000114271369 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 363
40  QuartzCore                          0x00000001142711ea _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
41  QuartzCore                          0x00000001141e4fb8 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 252
42  QuartzCore                          0x00000001141e6030 _ZN2CA11Transaction6commitEv + 394
43  QuartzCore                          0x00000001141e669d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
44  CoreFoundation                      0x0000000110a27dc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
45  CoreFoundation                      0x0000000110a27d37 __CFRunLoopDoObservers + 391
46  CoreFoundation                      0x0000000110a07522 __CFRunLoopRun + 946
47  CoreFoundation                      0x0000000110a06d83 CFRunLoopRunSpecific + 467
48  GraphicsServices                    0x0000000112dbdf04 GSEventRunModal + 161
49  UIKit                               0x000000010f357e33 UIApplicationMain + 1010
50  PSTappsperance                      0x000000010f092653 main + 115
51  libdyld.dylib                       0x00000001114b05fd start + 1
52  ???                                 0x0000000000000001 0x0 + 1
)libc++abi.dylib: terminating with uncaught exception of type NSException
解决了。 这是因为自动布局限制

有些标签无法确定其宽度

但为什么只在iOS 8上工作? 我固定了两个约束以确定Xcode 6中的宽度

Trailing Space to: superview
Leading Space to: superview

固定约束时,有一个选项“约束到边距”,默认情况下在Xcode 6中选中该选项。而旧版本不支持这一点。

你说得对@Kyle。这是由于自动布局约束导致的@在我的例子中,Mazen也是“第一次基线对齐”,将其移除并开始工作。以下是一些检测/解决问题的检查

  • 要检测导致此错误的情节提要,可以执行快速检查。在“文件检查器”中,取消选中所选情节提要的“使用自动布局”。现在,清理并构建您的应用程序。如果仍然得到相同的错误,则表示导致此错误的约束在另一个故事板或代码中

  • 识别序列图像板后,请使用“添加缺少的约束”或其他类似选项解决序列图像板显示的错误和警告

  • 筛选导致此错误的约束。一次删除3-4个约束(可以删除更多约束以加快速度),以检查错误是否已解决。解决错误后,确定导致此错误的确切约束

  • 关于“对保证金的限制”。在我的例子中,这在一些约束条件下被检查,但它不会导致iOS8下面的任何错误/警告

  • 您可以使用此链接解决自动布局问题


  • 希望这能对其他人有所帮助。

    当您在
    iOS 7
    上的限制中使用边距和基线运行应用程序时,会出现此崩溃

    要查找并删除所有虚拟约束字符串,可以执行以下操作:
    Xcode
    无法在
    Interface Builder
    中正确突出显示所有这些约束,因此您可以使用此解决方案:

  • 关闭
    Xcode
  • 在您喜爱的文本编辑器中打开故事板文件
  • 使用regex:
    (\w)Margin“
    查找所有匹配项,并将所有匹配项替换为模式:
    \1”
    (regex版本是Sublime 2中使用的版本)
  • 使用以下模式查找并从情节提要文件中删除所有字符串:
    *“基线”。*\n
  • 现在保存文件并在
    Xcode
  • 修复所有出现的未对齐:查找所有警告并按u“更新所有视图的约束”保存所有视图的原始位置
  • 利润

  • 更新:
    我发现“基线”约束也会导致崩溃,但Xcode没有显示任何关于这些约束的警告

    重置iPhone模拟器。清理所有,构建和运行程序。我也有同样的问题,并且观察到这个问题是由自动布局约束引起的。通过更新最近添加的约束来检查这些约束。。这将帮助其他人……:)在我的例子中,它是“基线对齐”,删除了它,workedI多次遇到这个问题。每次都是不同的自动布局问题。关于异常最糟糕的事情是,它被捕获在主体中,因此您不知道问题的来源。如果使用CollectionView,请在cellForItemAtIndexPath中设置断点以查找导致问题的单元格。如何解决问题?我必须从头开始设置自动布局约束吗?如果我没有设置任何约束怎么办?太好了!这解决了我撞车的麻烦,也让我更深入地探究了造成撞车的原因。更多讨论请访问“谢谢!和我一样,第4步,删除所有包含“基线”属性的行。