对于那些已经通过cs193p学习的人,我实际上正在完成最新 class 的第三次作业。
我什至已经使用Martin Mandl的出色博客作为解决大多数问题的参考。
然而!
对于那些不知道的人,我正在构建一个简单的标签栏应用程序。代码本身中的所有功能都在起作用。我可以稍作休息,直到-(void)viewDidLoad之后才发生错误。这是一个与情节提要有关的问题。
这是整个调用堆栈和前面的错误详细信息。有任何想法吗?
2014-08-29 12:00:46.749 Matchismo[19897:60b] View hierarchy unprepared for constraint.
Constraint: <NSIBPrototypingLayoutConstraint:0x8d5c440 'IB auto generated at build time for view with fixed frame' UIButton:0x8d59700.left == UIView:0x8d5a800.left + 20>
Container hierarchy:
<UIView: 0x8d5a800; frame = (0 0; 320 568); autoresize = RM+BM; layer = <CALayer: 0x8d5a860>>
| <UIButton: 0x8d55b80; frame = (68 72; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d55c70>>
| <UIButton: 0x8d4cff0; frame = (116 72; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d4d0e0>>
| <UIButton: 0x8d57fa0; frame = (164 72; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d58090>>
| <UIButton: 0x8d56400; frame = (212 72; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d564f0>>
| <UIButton: 0x8d561e0; frame = (260 72; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d562d0>>
| <UIButton: 0x8d56a60; frame = (20 120; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d56b50>>
| <UIButton: 0x8d58600; frame = (68 120; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d586f0>>
| <UIButton: 0x8d56620; frame = (116 120; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d56710>>
| <UIButton: 0x8d57b60; frame = (164 120; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d57c50>>
| <UIButton: 0x8d581c0; frame = (212 120; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d582b0>>
| <UIButton: 0x8d56c80; frame = (260 120; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d56d70>>
| <UIButton: 0x8d56ea0; frame = (20 168; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d56f90>>
| <UIButton: 0x8d55da0; frame = (68 168; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d55e90>>
| <UIButton: 0x8d58c60; frame = (116 168; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d58d50>>
| <UIButton: 0x8d59920; frame = (164 168; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d59a10>>
| <UIButton: 0x8d4d1f0; frame = (212 168; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d4d2e0>>
| <UIButton: 0x8d58a40; frame = (260 168; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d58b30>>
| <UIButton: 0x8d583e0; frame = (20 216; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d584d0>>
| <UIButton: 0x8d58e80; frame = (68 216; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d58f70>>
| <UIButton: 0x8d57940; frame = (116 216; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d57a30>>
| <UIButton: 0x8d570c0; frame = (164 216; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d571b0>>
| <UIButton: 0x8d58820; frame = (212 216; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d58910>>
| <UIButton: 0x8d572e0; frame = (260 216; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d573d0>>
| <UIButton: 0x8d57d80; frame = (20 264; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d57e70>>
| <UIButton: 0x8d56840; frame = (68 264; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d56930>>
| <UIButton: 0x8d590a0; frame = (116 264; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d59190>>
| <UIButton: 0x8d594e0; frame = (164 264; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d595d0>>
| <UIButton: 0x8d55fc0; frame = (212 264; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d560b0>>
| <UIButton: 0x8d4cb90; frame = (260 264; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d4c620>>
| <UIButton: 0x8d592c0; frame = (20 312; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d593b0>>
| <UIButton: 0x8d57500; frame = (68 312; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d575f0>>
| <UIButton: 0x8d4e990; frame = (116 312; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d4ea80>>
| <UIButton: 0x8d59b40; frame = (164 312; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d59c30>>
| <UIButton: 0x8d4f6c0; frame = (212 312; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d4f7b0>>
| <UIButton: 0x8d57720; frame = (260 312; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d57810>>
| <UILabel: 0x8d5a550; frame = (20 393; 222 21); text = 'Score: 0'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x8d5a600>>
| <UIButton: 0x8d59d80; frame = (250 389; 50 30); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d59e70>>
| <UILabel: 0x8d5a310; frame = (20 360; 280 21); text = ''; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x8d539d0>>
| <_UILayoutGuide: 0x8d5a9a0; frame = (0 0; 0 0); hidden = YES; layer = <CALayer: 0x8d5aa10>>
| <_UILayoutGuide: 0x8d5aab0; frame = (0 0; 0 0); hidden = YES; layer = <CALayer: 0x8d5ab20>>
View not found in container hierarchy: <UIButton: 0x8d59700; frame = (20 72; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d597f0>>
That view's superview: NO SUPERVIEW
2014-08-29 12:00:46.756 Matchismo[19897:60b] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to install constraint on view. Does the constraint reference something from outside the subtree of the view? That's illegal. constraint:<NSIBPrototypingLayoutConstraint:0x8d5c440 'IB auto generated at build time for view with fixed frame' UIButton:0x8d59700.left == UIView:0x8d5a800.left + 20> view:<UIView: 0x8d5a800; frame = (0 0; 320 568); autoresize = RM+BM; layer = <CALayer: 0x8d5a860>>'
*** First throw call stack:
(
0 CoreFoundation 0x01a401e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0158d8e5 objc_exception_throw + 44
2 CoreFoundation 0x01a3ffbb +[NSException raise:format:] + 139
3 Foundation 0x011c655f -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 197
4 Foundation 0x011c99ad -[NSLayoutConstraint _addToEngine:] + 56
5 UIKit 0x008ea974 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 515
6 Foundation 0x0134068c -[NSISEngine withBehaviors:performModifications:] + 107
7 Foundation 0x011d03c5 -[NSISEngine withAutomaticOptimizationDisabled:] + 48
8 UIKit 0x008eae40 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 63
9 UIKit 0x008ea754 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 476
10 UIKit 0x008eae48 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 71
11 UIKit 0x008ea54f -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 223
12 UIKit 0x008ea46b -[UIView(AdditionalLayoutSupport) _parentalLayoutEngineDidChangeTo:] + 55
13 UIKit 0x008ea850 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 223
14 Foundation 0x0134068c -[NSISEngine withBehaviors:performModifications:] + 107
15 Foundation 0x011d03c5 -[NSISEngine withAutomaticOptimizationDisabled:] + 48
16 UIKit 0x008eae40 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 63
17 UIKit 0x008ea754 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 476
18 UIKit 0x008eae48 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 71
19 UIKit 0x008ea54f -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 223
20 UIKit 0x002af24d __40-[UIView(Hierarchy) layoutBelowIfNeeded]_block_invoke + 416
21 Foundation 0x0134068c -[NSISEngine withBehaviors:performModifications:] + 107
22 Foundation 0x011d03c5 -[NSISEngine withAutomaticOptimizationDisabled:] + 48
23 UIKit 0x002aef1a -[UIView(Hierarchy) layoutBelowIfNeeded] + 327
24 UIKit 0x002aedcd -[UIView(Hierarchy) layoutIfNeeded] + 74
25 UIKit 0x0039ca2c -[UITabBarController _layoutViewController:] + 296
26 UIKit 0x0039cbd4 -[UITabBarController _wrapperViewForViewController:] + 248
27 UIKit 0x003a4141 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 441
28 UIKit 0x003a3943 -[UITabBarController transitionFromViewController:toViewController:] + 63
29 UIKit 0x0039fbed -[UITabBarController _setSelectedViewController:] + 281
30 UIKit 0x0039facc -[UITabBarController setSelectedViewController:] + 180
31 UIKit 0x003a383f -[UITabBarController _tabBarItemClicked:] + 312
32 libobjc.A.dylib 0x0159f880 -[NSObject performSelector:withObject:withObject:] + 77
33 UIKit 0x0024f3b9 -[UIApplication sendAction:to:from:forEvent:] + 108
34 UIKit 0x0024f345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
35 UIKit 0x00513629 -[UITabBar _sendAction:withEvent:] + 479
36 libobjc.A.dylib 0x0159f82b -[NSObject performSelector:withObject:] + 70
37 UIKit 0x0024f3b9 -[UIApplication sendAction:to:from:forEvent:] + 108
38 UIKit 0x0024f345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
39 UIKit 0x00350bd1 -[UIControl sendAction:to:forEvent:] + 66
40 UIKit 0x00350fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
41 UIKit 0x00350c06 -[UIControl sendActionsForControlEvents:] + 48
42 UIKit 0x0051823d -[UITabBar(Static) _buttonUp:] + 123
43 libobjc.A.dylib 0x0159f880 -[NSObject performSelector:withObject:withObject:] + 77
44 UIKit 0x0024f3b9 -[UIApplication sendAction:to:from:forEvent:] + 108
45 UIKit 0x0024f345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
46 UIKit 0x00350bd1 -[UIControl sendAction:to:forEvent:] + 66
47 UIKit 0x00350fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
48 UIKit 0x00350243 -[UIControl touchesEnded:withEvent:] + 641
49 UIKit 0x0028eddd -[UIWindow _sendTouchesForEvent:] + 852
50 UIKit 0x0028f9d1 -[UIWindow sendEvent:] + 1117
51 UIKit 0x002615f2 -[UIApplication sendEvent:] + 242
52 UIKit 0x0024b353 _UIApplicationHandleEventQueue + 11455
53 CoreFoundation 0x019c977f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
54 CoreFoundation 0x019c910b __CFRunLoopDoSources0 + 235
55 CoreFoundation 0x019e61ae __CFRunLoopRun + 910
56 CoreFoundation 0x019e59d3 CFRunLoopRunSpecific + 467
57 CoreFoundation 0x019e57eb CFRunLoopRunInMode + 123
58 GraphicsServices 0x03a345ee GSEventRunModal + 192
59 GraphicsServices 0x03a3442b GSEventRun + 104
60 UIKit 0x0024df9b UIApplicationMain + 1225
61 Matchismo 0x00009c5d main + 141
62 libdyld.dylib 0x02087701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
最佳答案
向下滚动一点:
View not found in container hierarchy:
<UIButton: 0x8d59700; frame = (20 72; 40 40); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x8d597f0>>
That view's superview: NO SUPERVIEW
此
UIButton
没有 super 视图。如果是在IB中创建的,请检查所有视图的树形视图;它可能不在正确的位置。关于ios - “未准备好约束的 View 层次结构...”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25574734/