使用autolayout时遇到了一个奇怪的问题。在我的xib中,我添加了一些Aspect Ratio约束。当我使用动画YES推动视图控制器时,它会与" NSInternalInconsistencyException"崩溃。并且"找不到传入头部UIView的传出行头:"类似的东西。当动画设置为NO时,似乎没问题。这发生在较低的ios8中。
然后我在AutoLayout views make app crash on popViewController找到了一些东西。我按照 narsil 的回答,以某种方式修复它。但我无法弄清楚原因。似乎我必须在viewWillDisappear方法离开控制器时删除每个宽高比约束。
还有其他方法可以解决这个问题吗?
这是日志,我只是删掉了部分内容。
[4150:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '<NSISEngine: 0x7f8749c3f650>{ Rows:
0x7f8749c5f500.posErrorMarker{id: 259} == 135 + 1*0x7f8749f80610.marker{id: 80} + 3*0x7f8749f80f00.marker{id: 178} + 1*0x7f8749f80f50.marker{id: 179} + -1*0x7f8749f81310.marker{id: 198} + 1*0x7f8749f81360.marker{id: 199} + 2*0x7f8749f81400.marker{id: 203} + 1*0x7f8749f81770.marker{id: 221} + 1*0x7f8749f81810.marker{id: 224} + -1*0x7f8749f82b30.marker{id: 235} + -1*0x7f8749f82bd0.marker{id: 239} + 1*0x7f8749f82cc0.marker{id: 245} + 1*0x7f8749f82d10.marker{id: 247} + 1*0x7f8749c5f500.negError{id: 260} + 3*0x7f8749f6dc30.posErrorMarker{id: 343} + -3*0x7f8749f6dc30.negError{id: 344}
0x7f8749c63650.negError{id: 288} == 0 + -1*0x7f8749f80f00.marker{id: 178} + -1*0x7f8749f81400.marker{id: 203} + 1*0x7f8749c63650.posErrorMarker{id: 287} + -1*0x7f8749f6dc30.posErrorMarker{id: 343} + 1*0x7f8749f6dc30.negError{id: 344}
0x7f8749c63e50.posErrorMarker{id: 289} == 284 + -9.48148*0x7f8749f80570.marker{id: 79} + -0.333333*0x7f8749f80fa0.marker{id: 181} + -0.333333*0x7f8749f81090.marker{id: 186} + -0.666667*0x7f8749f810e0.marker{id: 188} + 0.333333*0x7f8749f81130.marker{id: 189} + -0.333333*0x7f8749f811d0.marker{id: 191} + -0.333333*0x7f8749f81220.marker{id: 194} + 1*0x7f8749f812c0.marker{id: 197} + 0.666667*0x7f8749f82c70.marker{id: 244} + 4.74074*0x7f8749c5f580.posErrorMarker{id: 261} + -4.74074*0x7f8749c5f580.negError{id: 262} + 1*0x7f8749c63e50.negError{id: 290}
Statistics:
171 rows. Variable counts:
1 -> 40
2 -> 50
3 -> 7
4 -> 11
5 -> 6
6 -> 5
7 -> 5
8 -> 2
9 -> 4
10 -> 6
11 -> 6
12 -> 4
13 -> 6
14 -> 5
15 -> 3
16 -> 4
17 -> 4
19 -> 3
}: internal error. Cannot find an outgoing row head for incoming head UILabel:0x7f874c05b950.Width{id: 5939}, which should never happen.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000106cda495 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010674a99e objc_exception_throw + 43
2 CoreFoundation 0x0000000106cda2ad +[NSException raise:format:] + 205
3 Foundation 0x0000000106338054 -[NSISEngine minimizeConstantInObjectiveRowWithHead:] + 178
4 Foundation 0x0000000106337f22 -[NSISEngine optimize] + 147
5 Foundation 0x00000001064802e3 -[NSISEngine withBehaviors:performModifications:] + 192
6 UIKit 0x0000000107364889 -[UIView(Hierarchy) _postMovedFromSuperview:] + 321
7 UIKit 0x0000000107362f42 __UIViewWasRemovedFromSuperview + 206
8 UIKit 0x0000000107362b9e -[UIView(Hierarchy) removeFromSuperview] + 218
9 UIKit 0x0000000107425069 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 320
10 UIKit 0x000000010741dfdd __49-[UINavigationController _startCustomTransition:]_block_invoke + 138
11 UIKit 0x0000000107973c2a -[_UIViewControllerTransitionContext completeTransition:] + 78
12 UIKit 0x0000000107306da4 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke103 + 605
13 UIKit 0x00000001073696e8 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 299
14 UIKit 0x000000010735568e -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 235
15 UIKit 0x0000000107355941 -[UIViewAnimationState animationDidStop:finished:] + 78
16 QuartzCore 0x000000010a920134 _ZN2CA5Layer23run_animation_callbacksEPv + 310
17 libdispatch.dylib 0x000000010868172d _dispatch_client_callout + 8
18 libdispatch.dylib 0x00000001086713fc _dispatch_main_queue_callback_4CF + 354
19 CoreFoundation 0x0000000106d38289 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
20 CoreFoundation 0x0000000106c85854 __CFRunLoopRun + 1764
21 CoreFoundation 0x0000000106c84d83 CFRunLoopRunSpecific + 467
22 GraphicsServices 0x000000010900df04 GSEventRunModal + 161
23 UIKit 0x0000000107310e33 UIApplicationMain + 1010
24 Mytest 0x00000001060b10a3 main + 115
25 libdyld.dylib 0x00000001089065fd start + 1
26 ??? 0x0000000000000001 0x0 + 1
)