发生以下崩溃。 Xcode没有(严肃地)报告任何遗漏的约束,并且每次都不会发生崩溃。 很明显我在某个地方有一个错误 - 但我在哪里开始调查?
修改:
因此,在创建异常断点之后 - 我发现崩溃的线程是自动布局代码。 不同的线程具有以下内容
这并不令人震惊,这是对UILabel的重新调整 - 现在是什么?
崩溃转储:
RemoveVariableFromSortedPriorityVectorList(NSISObjectiveLinearExpression *, NSISVariable *)(), /SourceCache/Foundation_Sim/Foundation-1047.25/Layout.subproj/IncrementalSimplex/NSISObjectiveLinearExpression.m:136
2014-11-03 00:28:14.899 Cookila copy[3470:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Missing variable UILabel:0x78885670.Width{id: 5777} in variablesSortedByPriorityVectors'
*** First throw call stack:
(
0 CoreFoundation 0x03ba91e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0386a8e5 objc_exception_throw + 44
2 CoreFoundation 0x03ba9048 +[NSException raise:format:arguments:] + 136
3 Foundation 0x03307b20 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 101
4 Foundation 0x03414df4 RemoveVariableFromSortedPriorityVectorList + 386
5 Foundation 0x0329af95 -[NSISObjectiveLinearExpression removeVariable:] + 30
6 Foundation 0x034152b9 -[NSISObjectiveLinearExpression replaceVariable:withExpression:processVariableNewToReceiver:processVariableDroppedFromReceiver:] + 76
7 Foundation 0x0329b3f7 -[NSISEngine substituteOutAllOccurencesOfBodyVar:withExpression:] + 897
8 Foundation 0x0340b5cf -[NSISEngine pivotToMakeBodyVar:newHeadOfRowWithHead:andDropRow:] + 421
9 Foundation 0x0329a098 -[NSISEngine minimizeConstantInObjectiveRowWithHead:] + 287
10 Foundation 0x0340db9d -[NSISEngine tryUsingArtificialVariableToAddConstraintWithMarker:rowBody:usingInfeasibilityHandlingBehavior:mutuallyExclusiveConstraints:] + 300
11 Foundation 0x03298fc3 -[NSISEngine tryToAddConstraintWithMarker:expression:integralizationAdjustment:mutuallyExclusiveConstraints:] + 780
12 Foundation 0x03417a77 -[NSLayoutConstraint _addLoweredExpression:toEngine:integralizationAdjustment:lastLoweredConstantWasRounded:mutuallyExclusiveConstraints:] + 283
13 Foundation 0x03294596 -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 252
14 UIKit 0x029ac30d -[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 451
15 UIKit 0x029ada4b -[UIView(UIConstraintBasedLayout) _constraints_didChangeAutoresizingConstraintsArrayForContainedView:] + 233
16 UIKit 0x029ad60e -[UIView(UIConstraintBasedLayout) _setAutoresizingConstraints:] + 240
17 UIKit 0x029adea0 -[UIView(UIConstraintBasedLayout) _updateAutoresizingConstraints] + 117
18 UIKit 0x029b77bf -[UIView(AdditionalLayoutSupport) updateConstraints] + 110
19 UIKit 0x029b7058 -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 239
20 UIKit 0x029b71d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122
21 UIKit 0x029b7157 __UIViewRecursionHelper + 40
22 CoreFoundation 0x03b4ac69 CFArrayApplyFunction + 57
23 UIKit 0x029b6ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147
24 UIKit 0x029b71d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122
25 UIKit 0x029b7157 __UIViewRecursionHelper + 40
26 CoreFoundation 0x03b4ac69 CFArrayApplyFunction + 57
27 UIKit 0x029b6ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147
28 UIKit 0x029b71d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122
29 UIKit 0x029b7157 __UIViewRecursionHelper + 40
30 CoreFoundation 0x03b4ac69 CFArrayApplyFunction + 57
31 UIKit 0x029b6ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147
32 UIKit 0x029b71d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122
33 UIKit 0x029b7157 __UIViewRecursionHelper + 40
34 CoreFoundation 0x03b4ac69 CFArrayApplyFunction + 57
35 UIKit 0x029b6ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147
36 UIKit 0x029b71d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122
37 UIKit 0x029b7157 __UIViewRecursionHelper + 40
38 CoreFoundation 0x03b4ac69 CFArrayApplyFunction + 57
39 UIKit 0x029b6ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147
40 UIKit 0x029b71d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122
41 UIKit 0x029b7157 __UIViewRecursionHelper + 40
42 CoreFoundation 0x03b4ac69 CFArrayApplyFunction + 57
43 UIKit 0x029b6ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147
44 UIKit 0x029b71d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122
45 UIKit 0x029b7157 __UIViewRecursionHelper + 40
46 CoreFoundation 0x03b4ac69 CFArrayApplyFunction + 57
47 UIKit 0x029b6ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147
48 UIKit 0x029b71d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122
49 UIKit 0x029b7157 __UIViewRecursionHelper + 40
50 CoreFoundation 0x03b4ac69 CFArrayApplyFunction + 57
51 UIKit 0x029b6ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147
52 UIKit 0x029b71d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122
53 UIKit 0x029b7157 __UIViewRecursionHelper + 40
54 CoreFoundation 0x03b4ac69 CFArrayApplyFunction + 57
55 UIKit 0x029b6ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147
56 UIKit 0x029b71d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122
57 UIKit 0x029ab878 __62-[UIWindow(UIConstraintBasedLayout) updateConstraintsIfNeeded]_block_invoke + 43
58 Foundation 0x0340e68c -[NSISEngine withBehaviors:performModifications:] + 107
59 Foundation 0x0329e3c5 -[NSISEngine withAutomaticOptimizationDisabled:] + 48
60 UIKit 0x029ab590 -[UIWindow(UIConstraintBasedLayout) updateConstraintsIfNeeded] + 225
61 UIKit 0x029b7836 -[UIView(AdditionalLayoutSupport) _updateConstraintsAtWindowLevelIfNeeded] + 85
62 UIKit 0x0237b324 -[UIView(Hierarchy) layoutSubviews] + 62
63 UIKit 0x02388964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
64 libobjc.A.dylib 0x0387c82b -[NSObject performSelector:withObject:] + 70
65 QuartzCore 0x021f045a -[CALayer layoutSublayers] + 148
66 QuartzCore 0x021e4244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
67 QuartzCore 0x021e40b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
68 QuartzCore 0x0214a7fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
69 QuartzCore 0x0214bb85 _ZN2CA11Transaction6commitEv + 393
70 QuartzCore 0x0214c258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
71 CoreFoundation 0x03b7136e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
72 CoreFoundation 0x03b712bf __CFRunLoopDoObservers + 399
73 CoreFoundation 0x03b4f254 __CFRunLoopRun + 1076
74 CoreFoundation 0x03b4e9d3 CFRunLoopRunSpecific + 467
75 CoreFoundation 0x03b4e7eb CFRunLoopRunInMode + 123
76 GraphicsServices 0x045815ee GSEventRunModal + 192
77 GraphicsServices 0x0458142b GSEventRun + 104
78 UIKit 0x02319f9b UIApplicationMain + 1225
79 Cookila copy 0x000e594d main + 141
80 libdyld.dylib 0x0415b701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
答案 0 :(得分:0)
如果它是UILabel
的调整大小你有约束我会尝试删除它有的约束,调整它然后设置新的约束(即使它们与前面的约束相同)。您可以编辑/覆盖该方法以重新标记标签删除并重新添加约束。
代码:
[label autoRemoveConstraintsAffectingView];
//Resize
//Add constraints
[self.view needsUpdateConstraints];
[self.view layoutIfNeeded];