我在iOS7上的自动布局问题上崩溃了(iOS8可以工作)
问题是 – UIButton指示(0x7b7780a0)不存在(当我查看UIView的recursiveDescription时).
我该如何调查?从哪儿开始?
编辑:
我遇到了这个答案,https://stackoverflow.com/a/27284071/429249确实我在回溯中有一个非常小的浮点数,但是 – 我没有在代码中添加约束,而我的所有乘数都是1
编辑:
给自己发了一个答案 – 然而https://stackoverflow.com/a/27284071/429249是一个很好的答案,最终指导我解决方案
碰撞:
2015-03-10 15:50:08.152 Cookila copy[5779:607] Objective: {objective 0x7b84c960: <750:-1.04308e-05,250:6.61612e-05> + <750:-1.04308e-07,250:8.9407e-08>*UIButton:0x7b6299c0.Width{id: 408} + <750:-2.23517e-08,250:8.9407e-08>*UIButton:0x7b661ad0.Width{id: 385} + <750:-1.86265e-07,250:8.9407e-08>*UIButton:0x7b7780a0.Width{id: 388} + <750:1.04308e-07,250:-1.3411e-07>*UIView:0x7b6547d0.Width{id: 419}} 2015-03-10 15:50:09.674 Cookila copy[5779:607] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException',reason: '<NSISEngine: 0x7b84c120>{ Rows: UILayoutContainerView:0x7b6505a0.Height{id: 118} == 960 + 1*0x7b7679b0.marker{id: 49} + 2*0x7b638350.marker{id: 135} UILayoutContainerView:0x7b6505a0.Width{id: 115} == 640 + 1*0x7b767980.marker{id: 46} + 2*0x7b6592b0.marker{id: 131} UILayoutContainerView:0x7b6505a0.minX{id: 121} == 0 + 2*0x7b642e00.marker{id: 130} + -1*0x7b6592b0.marker{id: 131} UILayoutContainerView:0x7b6505a0.minY{id: 122} == 0 + 2*0x7b657350.marker{id: 134} + -1*0x7b638350.marker{id: 135} UINavigationTransitionView:0x7b756bc0.Height{id: 110} == 960 + 1*0x7b7679b0.marker{id: 49} + 2*0x7b664d50.marker{id: 119} + 2*0x7b638350.marker{id: 135} UINavigationTransitionView:0x7b756bc0.Width{id: 107} == 640 + 1*0x7b767980.marker{id: 46} + 2*0x7b664cf0.marker{id: 116} + 2*0x7b6592b0.marker{id: 131} UINavigationTransitionView:0x7b756bc0.minX{id: 113} == 0 + 2*0x7b6584c0.marker{id: 112} + -1*0x7b664cf0.marker{id: 116} UINavigationTransitionView:0x7b756bc0.minY{id: 114} == 0 + 2*0x7b664d20.marker{id: 117} + -1*0x7b664d50.marker{id: 119} UIViewControllerWrapperView:0x7b77add0.Height{id: 102} == 960 + 1*0x7b7679b0.marker{id: 49} + 2*0x7b659c40.marker{id: 111} + 2*0x7b664d50.marker{id: 119} + 2*0x7b638350.marker{id: 135} UIViewControllerWrapperView:0x7b77add0.Width{id: 99} == 640 + 1*0x7b767980.marker{id: 46} + 2*0x7b655430.marker{id: 108} + 2*0x7b664cf0.marker{id: 116} + 2*0x7b6592b0.marker{id: 131} UIViewControllerWrapperView:0x7b77add0.minX{id: 105} == 0 + 2*0x7b655400.marker{id: 104} + -1*0x7b655430.marker{id: 108} UIViewControllerWrapperView:0x7b77add0.minY{id: 106} == 0 + 2*0x7b659c10.marker{id: 109} + -1*0x7b659c40.marker{id: 111} UIWindow:0x7b742a60.Height{id: 45} == 960 + 1*0x7b7679b0.marker{id: 49} UIWindow:0x7b742a60.Width{id: 42} == 640 + 1*0x7b767980.marker{id: 46} UIWindow:0x7b742a60.minX{id: 41} == 0 + 2*0x7b767710.marker{id: 40} + -0.5*0x7b767980.marker{id: 46} UIWindow:0x7b742a60.minY{id: 44} == 0 + 2*0x7b767840.marker{id: 43} + -0.5*0x7b7679b0.marker{id: 49} objective{id: 1} == {objective 0x7b84c960: <750:-1.04308e-05,250:-1.3411e-07>*UIView:0x7b6547d0.Width{id: 419}} Constraints: <NSAutoresizingMaskLayoutConstraint:0x7b638350 h=-&- v=-&- UILayoutContainerView:0x7b6505a0.height == UIWindow:0x7b742a60.height> Marker:0x7b638350.marker{id: 135} <NSAutoresizingMaskLayoutConstraint:0x7b642e00 h=-&- v=-&- UILayoutContainerView:0x7b6505a0.midX == UIWindow:0x7b742a60.midX> Marker:0x7b642e00.marker{id: 130} <NSAutoresizingMaskLayoutConstraint:0x7b655400 h=-&- v=-&- UIViewControllerWrapperView:0x7b77add0.midX == UINavigationTransitionView:0x7b756bc0.midX> Marker:0x7b655400.marker{id: 104} <NSAutoresizingMaskLayoutConstraint:0x7b655430 h=-&- v=-&- UIViewControllerWrapperView:0x7b77add0.width == UINavigationTransitionView:0x7b756bc0.width> Marker:0x7b655430.marker{id: 108} <NSAutoresizingMaskLayoutConstraint:0x7b657350 h=-&- v=-&- UILayoutContainerView:0x7b6505a0.midY == UIWindow:0x7b742a60.midY> Marker:0x7b657350.marker{id: 134} <NSAutoresizingMaskLayoutConstraint:0x7b6584c0 h=-&- v=-&- UINavigationTransitionView:0x7b756bc0.midX == UILayoutContainerView:0x7b6505a0.midX> Marker:0x7b6584c0.marker{id: 112} <NSAutoresizingMaskLayoutConstraint:0x7b6592b0 h=-&- v=-&- UILayoutContainerView:0x7b6505a0.width == UIWindow:0x7b742a60.width> Marker:0x7b6592b0.marker{id: 131} <NSAutoresizingMaskLayoutConstraint:0x7b659c10 h=-&- v=-&- UIViewControllerWrapperView:0x7b77add0.midY == UINavigationTransitionView:0x7b756bc0.midY> Marker:0x7b659c10.marker{id: 109} <NSAutoresizingMaskLayoutConstraint:0x7b659c40 h=-&- v=-&- UIViewControllerWrapperView:0x7b77add0.height == UINavigationTransitionView:0x7b756bc0.height> Marker:0x7b659c40.marker{id: 111} <NSAutoresizingMaskLayoutConstraint:0x7b664cf0 h=-&- v=-&- UINavigationTransitionView:0x7b756bc0.width == UILayoutContainerView:0x7b6505a0.width> Marker:0x7b664cf0.marker{id: 116} <NSAutoresizingMaskLayoutConstraint:0x7b664d20 h=-&- v=-&- UINavigationTransitionView:0x7b756bc0.midY == UILayoutContainerView:0x7b6505a0.midY> Marker:0x7b664d20.marker{id: 117} <NSAutoresizingMaskLayoutConstraint:0x7b664d50 h=-&- v=-&- UINavigationTransitionView:0x7b756bc0.height == UILayoutContainerView:0x7b6505a0.height> Marker:0x7b664d50.marker{id: 119} <NSAutoresizingMaskLayoutConstraint:0x7b767980 h=--- v=--- H:[UIWindow:0x7b742a60(320)]> Marker:0x7b767980.marker{id: 46} <NSAutoresizingMaskLayoutConstraint:0x7b7679b0 h=--- v=--- V:[UIWindow:0x7b742a60(480)]> Marker:0x7b7679b0.marker{id: 49} <_UIWindowAnchoringConstraint:0x7b767710 h=--- v=--- UIWindow:0x7b742a60.midX == + 160> Marker:0x7b767710.marker{id: 40} <_UIWindowAnchoringConstraint:0x7b767840 h=--- v=--- UIWindow:0x7b742a60.midY == + 240> Marker:0x7b767840.marker{id: 43} Integralization Adjustments: (none) Statistics: 16 rows. Variable counts: 1 -> 2 2 -> 10 3 -> 2 4 -> 2 }: internal error. Cannot find an outgoing row head for incoming head UIButton:0x7b7780a0.Width{id: 388},which should never happen.' *** First throw call stack: ( 0 CoreFoundation 0x03e051e4 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x03b848e5 objc_exception_throw + 44 2 CoreFoundation 0x03e04fbb +[NSException raise:format:] + 139 3 Foundation 0x035b4079 -[NSISEngine minimizeConstantInObjectiveRowWithHead:] + 256 4 Foundation 0x035b3ee3 -[NSISEngine optimize] + 183 5 Foundation 0x037286d8 -[NSISEngine withBehaviors:performModifications:] + 183 6 Foundation 0x035b83c5 -[NSISEngine withAutomaticOptimizationDisabled:] + 48 7 UIKit 0x02695830 -[UIView(Hierarchy) _postMovedFromSuperview:] + 313 8 UIKit 0x026a0dd4 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1875 9 UIKit 0x02693c4f -[UIView(Hierarchy) insertSubview:atIndex:] + 64 10 UIKit 0x02628089 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke + 1896 11 UIKit 0x0269a81f +[UIView(Animation) performWithoutAnimation:] + 82 12 UIKit 0x026274f6 -[_UINavigationParallaxTransition animateTransition:] + 1155 13 UIKit 0x0276e3ae -[UINavigationController _startCustomTransition:] + 3446 14 UIKit 0x0277a8f7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688 15 UIKit 0x0277b4e9 -[UINavigationController __viewWillLayoutSubviews] + 57 16 UIKit 0x028bc0d1 -[UILayoutContainerView layoutSubviews] + 213 17 UIKit 0x026a3964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355 18 libobjc.A.dylib 0x03b9682b -[NSObject performSelector:withObject:] + 70 19 QuartzCore 0x0250845a -[CALayer layoutSublayers] + 148 20 QuartzCore 0x024fc244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380 21 QuartzCore 0x024fc0b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26 22 QuartzCore 0x024627fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294 23 QuartzCore 0x02463b85 _ZN2CA11Transaction6commitEv + 393 24 QuartzCore 0x02464258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92 25 CoreFoundation 0x03dcd36e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30 26 CoreFoundation 0x03dcd2bf __CFRunLoopDoObservers + 399 27 CoreFoundation 0x03dab254 __CFRunLoopRun + 1076 28 CoreFoundation 0x03daa9d3 CFRunLoopRunSpecific + 467 29 CoreFoundation 0x03daa7eb CFRunLoopRunInMode + 123 30 GraphicsServices 0x0585b5ee GSEventRunModal + 192 31 GraphicsServices 0x0585b42b GSEventRun + 104 32 UIKit 0x02634f9b UIApplicationMain + 1225 33 Cookila copy 0x0008a0fd main + 141 34 libdyld.dylib 0x048276d9 start + 1 35 ??? 0x00000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException
self.view recursiveDescription(在ViewWillAppear中的断点上运行之前运行):
<UIView: 0x7b67d660; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x7b67d6c0>> | <UIImageView: 0x7b67cfb0; frame = (0 0; 320 568); opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x7b67d030>> | <UIButton: 0x7b674310; frame = (160 515; 75 30); opaque = NO; autoresize = RM+BM; tag = 115; layer = <CALayer: 0x7b674400>> | <UIButton: 0x7b67ecf0; frame = (235 515; 75 30); opaque = NO; autoresize = RM+BM; tag = 116; layer = <CALayer: 0x7b67ede0>> | <UIButton: 0x7b67ccd0; frame = (85 515; 75 30); opaque = NO; autoresize = RM+BM; tag = 114; layer = <CALayer: 0x7b67cdc0>> | <UIButton: 0x7b6764c0; frame = (10 455; 75 60); opaque = NO; autoresize = RM+BM; tag = 13; layer = <CALayer: 0x7b6765b0>> | <UIButton: 0x7b6745d0; frame = (85 455; 75 60); opaque = NO; autoresize = RM+BM; tag = 14; layer = <CALayer: 0x7b6746c0>> | <UIButton: 0x7b67f1f0; frame = (160 455; 75 60); opaque = NO; autoresize = RM+BM; tag = 15; layer = <CALayer: 0x7b67f2e0>> | <UIButton: 0x7b67c890; frame = (10 515; 75 30); opaque = NO; autoresize = RM+BM; tag = 113; layer = <CALayer: 0x7b67f9c0>> | <UIButton: 0x7b672dc0; frame = (235 455; 75 60); opaque = NO; autoresize = RM+BM; tag = 16; layer = <CALayer: 0x7b679950>> | <UIView: 0x7b67d520; frame = (0 428; 320 27); autoresize = RM+BM; layer = <CALayer: 0x7b67d580>> | <UIButton: 0x7b67f430; frame = (160 398; 75 30); opaque = NO; autoresize = RM+BM; tag = 111; layer = <CALayer: 0x7b67f520>> | <UIButton: 0x7b6733f0; frame = (235 398; 75 30); opaque = NO; autoresize = RM+BM; tag = 112; layer = <CALayer: 0x7b67a9c0>> | <UIButton: 0x7b675850; frame = (85 398; 75 30); opaque = NO; autoresize = RM+BM; tag = 110; layer = <CALayer: 0x7b675940>> | <UIButton: 0x7b656330; frame = (10 338; 75 60); opaque = NO; autoresize = RM+BM; tag = 9; layer = <CALayer: 0x7b642d40>> | <UIButton: 0x7b6753a0; frame = (85 338; 75 60); opaque = NO; autoresize = RM+BM; tag = 10; layer = <CALayer: 0x7b665bd0>> | <UIButton: 0x7b6737f0; frame = (160 338; 75 60); opaque = NO; autoresize = RM+BM; tag = 11; layer = <CALayer: 0x7b6738e0>> | <UIButton: 0x7b6762e0; frame = (10 398; 75 30); opaque = NO; autoresize = RM+BM; tag = 109; layer = <CALayer: 0x7b6763d0>> | <UIButton: 0x7b675ba0; frame = (235 338; 75 60); opaque = NO; autoresize = RM+BM; tag = 12; layer = <CALayer: 0x7b673a20>> | <UIView: 0x7b67d3d0; frame = (0 311; 320 27); autoresize = RM+BM; layer = <CALayer: 0x7b67d430>> | <UIButton: 0x7b675d50; frame = (160 281; 75 30); opaque = NO; autoresize = RM+BM; tag = 107; layer = <CALayer: 0x7b675e40>> | <UIButton: 0x7b663970; frame = (235 281; 75 30); opaque = NO; autoresize = RM+BM; tag = 108; layer = <CALayer: 0x7b663a60>> | <UIButton: 0x7b675580; frame = (85 281; 75 30); opaque = NO; autoresize = RM+BM; tag = 106; layer = <CALayer: 0x7b675670>> | <UIButton: 0x7b665a00; frame = (10 221; 75 60); opaque = NO; autoresize = RM+BM; tag = 5; layer = <CALayer: 0x7b663c40>> | <UIButton: 0x7b67ca90; frame = (85 221; 75 60); opaque = NO; autoresize = RM+BM; tag = 6; layer = <CALayer: 0x7b67cb80>> | <UIButton: 0x7b674150; frame = (160 221; 75 60); opaque = NO; autoresize = RM+BM; tag = 7; layer = <CALayer: 0x7b6564b0>> | <UIButton: 0x7b6734e0; frame = (10 281; 75 30); opaque = NO; autoresize = RM+BM; tag = 105; layer = <CALayer: 0x7b6796e0>> | <UIButton: 0x7b67efb0; frame = (235 221; 75 60); opaque = NO; autoresize = RM+BM; tag = 8; layer = <CALayer: 0x7b67f0a0>> | <UIButton: 0x7b67f700; frame = (160 164; 75 30); opaque = NO; autoresize = RM+BM; tag = 103; layer = <CALayer: 0x7b67f7f0>> | <UIButton: 0x7b676020; frame = (235 164; 75 30); opaque = NO; autoresize = RM+BM; tag = 104; layer = <CALayer: 0x7b676110>> | <UIButton: 0x7b676700; frame = (85 164; 75 30); opaque = NO; autoresize = RM+BM; tag = 102; layer = <CALayer: 0x7b674ea0>> | <UIButton: 0x7b67eab0; frame = (10 104; 75 60); opaque = NO; autoresize = RM+BM; tag = 1; layer = <CALayer: 0x7b67eba0>> | <UIButton: 0x7b674810; frame = (85 104; 75 60); opaque = NO; autoresize = RM+BM; tag = 2; layer = <CALayer: 0x7b674900>> | <UIButton: 0x7b674a50; frame = (10 164; 75 30); opaque = NO; autoresize = RM+BM; tag = 101; layer = <CALayer: 0x7b674b40>> | <UIButton: 0x7b642bd0; frame = (235 104; 75 60); opaque = NO; autoresize = RM+BM; tag = 4; layer = <CALayer: 0x7b6752a0>> | <UIView: 0x7b67d1f0; frame = (0 194; 320 27); autoresize = RM+BM; layer = <CALayer: 0x7b67d250>> | <UIButton: 0x7b675060; frame = (160 104; 75 60); opaque = NO; autoresize = RM+BM; tag = 3; layer = <CALayer: 0x7b675150>> | <UIButton: 0x7b67b7f0; frame = (258 20; 46 30); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x7b672b90>> | <_UILayoutGuide: 0x7b67d790; frame = (0 0; 0 0); hidden = YES; layer = <CALayer: 0x7b67d800>> | <_UILayoutGuide: 0x7b67c0a0; frame = (0 0; 0 0); hidden = YES; layer = <CALayer: 0x7b67c110>>
解决方法
显然,违规的UIButton位于ViewController中,我们走出(!)而不是在转换中创建的那个.
不知道为什么….
无论如何 – 有问题的约束是4:3的比例约束……