1

For those of you who've gone through cs193p, I'm actually completing the 3rd assignment currently for the latest course.

I've even used Martin Mandl's excellent blog as a reference to resolve most issues.

However!

For those that don't know, I'm building a simple tab bar app. All of the functionality in the code itself is working. I can put in breaks and it's not until AFTER -(void)viewDidLoad that the error occurs. This is an issue somehow related to storyboard.

Here's the entire call stack and preceding error details. Any ideas?

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
Meshach
  • 315
  • 1
  • 2
  • 16

1 Answers1

1

Scroll down a bit:

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

This UIButton doesn't have a superview. If you made it in IB, check the tree view of all your views; it's probably not in the right place.

Aaron Brager
  • 65,323
  • 19
  • 161
  • 287
  • I did create it in IB, good catch with the NO SUPERVIEW. However, if I remove the button at 20 72, then that error is listed for the next button at 68 72. – Meshach Aug 29 '14 at 19:40
  • Perhaps multiple buttons don't have a superview. – Aaron Brager Aug 29 '14 at 20:43
  • I rebuilt the entire view, from scratch, in IB. These two separate scenes are using the SAME parent view controller (though they've been extended slightly differently), one works, this one fails. – Meshach Aug 29 '14 at 22:30
  • The button has a left constraint of 20 points to a view that doesn't exist in the same hierarchy as the button. It's impossible to meet this constraint. This button is either never added, or is removed from the hierarchy, but your question doesn't show any of the related code, so it's impossible to tell why this is happening. – Aaron Brager Aug 30 '14 at 00:05
  • As it turns out, I had added a 'subview' in the -(void)viewWillAppear and then when the UITabView segue'd do another view, that subview was somehow causing the UIButtons to error! Very confusing.... So, you're right, the code was, behind the scenes, removing the UIButton's from the hierarchy, without ever actually happening in any place I could get to from standard debugging.... – Meshach Aug 30 '14 at 01:53