I've implemented a dropdown menu into my iOS app that calls functions to navigate between different storyboards. Each element in that menu calls the following function in the AppDelegate class with a different storyboard name:
(void)changeController:(NSString*)storyboardName
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:[NSBundle mainBundle]];
//initialize the new view
currentView = [storyboard instantiateInitialViewController];
currentView.view.alpha = 0.0;
currentView.view.frame = currentView.view.bounds;
currentView.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
//the app crashes on this line with a Thread 1: signal SIGARBT message
self.window.rootViewController = currentView;
[self.window makeKeyAndVisible];
//animate with a fade transition
[UIView animateWithDuration:transitionDuration
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{currentView.view.alpha = 1.0;}
completion:^(BOOL finished){}];
}
The problem is that the function that gets called crashes the app inconsistently. It works from some screens and not others. And even worse, it sometimes works on screens that it normally crashes on.
There are two error messages that get dumped to the console, and they are (I've added line breaks for readability):
Objective: {
objective 0x15e4b3c0: <750:-1.64135e-05> + <750:8.34465e-08>
*<orphaned without delegate (bug!):0x1703c790>{id: 188} + <750:4.17233e-08>
*<orphaned without delegate (bug!):0x1703c980>{id: 192} + <750:-2.68221e-08>
*UIView:0x170c6e40.Height{id: 1091}
}
and
uncaught exception: <NSISEngine: 0x15e0b380>{ Rows:
UIWindow:0x15db3160.Height{id: 140} == 960 + 1*0x15dd03e0.marker{id: 144}
UIWindow:0x15db3160.Width{id: 137} == 640 + 1*0x15dd03b0.marker{id: 141}
UIWindow:0x15db3160.minX{id: 136} == 0 + 2*0x15dd0200.marker{id: 135} + -0.5*0x15dd03b0.marker{id: 141}
UIWindow:0x15db3160.minY{id: 139} == 0 + 2*0x15dd0350.marker{id: 138} + -0.5*0x15dd03e0.marker{id: 144}
objective{id: 1} == {
objective 0x15e4b3c0: <750:-1.64135e-05> + <750:8.34465e-08>
*<orphaned without delegate (bug!):0x1703c790>{id: 188} + <750:4.17233e-08>
*<orphaned without delegate (bug!):0x1703c980>{id: 192} + <750:-2.68221e-08>
*UIView:0x170c6e40.Height{id: 1091}}
Constraints:
<NSAutoresizingMaskLayoutConstraint:0x15dd03b0 h=--- v=--- H:[UIWindow:0x15db3160(320)]> Marker:0x15dd03b0.marker{id: 141}
<NSAutoresizingMaskLayoutConstraint:0x15dd03e0 h=--- v=--- V:[UIWindow:0x15db3160(480)]> Marker:0x15dd03e0.marker{id: 144}
<_UIWindowAnchoringConstraint:0x15dd0200 h=--- v=--- UIWindow:0x15db3160.midX == + 160> Marker:0x15dd0200.marker{id: 135}
<_UIWindowAnchoringConstraint:0x15dd0350 h=--- v=--- UIWindow:0x15db3160.midY == + 240> Marker:0x15dd0350.marker{id: 138}
Integralization Adjustments:
(none)
Statistics:
4 rows. Variable counts:
1 -> 2
2 -> 2
}: internal error. Cannot find an outgoing row head for incoming head UIView:0x170c6e40.Height{id: 1091}, which should never happen.
It's the last line that really confuses me, "internal error .... which should never happen."
I'm curious if anyone else has encountered this error, and how they tackled it.
Is this an issue with initializing the variable currentView, or perhaps something to do with the AppDelegate's window variable?
Is this really an issue with storyboard constraints? And if so, is there a limit to the number of constraints I can/should put on a single screen?
EDIT:
I figured out that the error was really only caused when navigating away from one particular storyboard. A constraint on the screen was throwing the error. So I added some code to the changeController: to programmatically remove the constraints from every subview and then remove every subview from the superview.
The problem was ultimately resolved when the constraints in the offending UIViewController were cleared and recreated.
Thanks for all your help and suggestions.