ios - '无法在 descriptionForLayoutAttribute_layoutItem_coefficient 中创建描述。有些东西是零

标签 ios objective-c xcode autolayout

首先,我有 3 个不同的 UIView 来替换 iPad Storyboard上的 Split View Controller 中的详细 View

它在 iOS8 iPad 上运行良好。但是,当我加载其中一个详细 View 时,应用程序在 iOS7 和 iOS 6 模拟器中运行时崩溃。

我只是假设这是因为我的 Storyboard 上的自动布局。

有人知道怎么解决吗?

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 7 上的约束条件下运行您的应用程序时,会出现此崩溃。

要查找并删除所有虚拟约束字符串,您可以这样做:

Xcode 未在 Interface Builder 中正确突出显示所有这些约束,因此您可以使用此解决方案:

  1. 关闭Xcode
  2. 在您喜欢的文本编辑器中打开 Storyboard文件
  3. 使用正则表达式查找所有匹配项:(\w)Margin" 并将所有匹配项替换为以下模式:\1" (正则表达式版本为Sublime 2 中使用的那个)
  4. 使用以下模式从 Storyboard文件中查找并删除所有字符串:.*"baseline".*\n
  5. 现在保存文件并在 Xcode 中打开它
  6. 修复所有出现的错位:找到所有警告并按_“更新所有 View 的约束”以保存所有 View 的原始位置。
  7. 利润!

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

关于ios - '无法在 descriptionForLayoutAttribute_layoutItem_coefficient 中创建描述。有些东西是零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26024906/

相关文章:

ios - UIPickerView - 多行行 - 需要布局建议

objective-c - 为什么即使我释放了大量内存以响应内存警告,iOS 也会终止我的应用程序?

ios - "IDELaunchErrorDomain"设备运行watchOS应用时出错

ios - 有没有办法仍然使用 Xcode 4 调试 iPhone 5s

xcode - 使用 Xcode 4 作为 Git difftool

ios - Swift 2.0 元组模式元素标签必须是 '_'

iOS Swift Core Data 生成带有项目命名空间的 NSManagedObject

ios - 在 Xcode 上的 2 个框架之间切换

ios - iOS 中的 Crashlytics 无法继续 "Build and run your app"步骤

ios - 使用 2 个排序描述符对数组进行排序