I had a UIStoryboard
with 10 or more UIViewControllers
and additional ContainerViews
. After layouting the views and customizing more and more, the UIStoryboard
got more and more lazy.
My approach was to setup the views inside single UIStoryboards
. Loading the controllers is done inside my Menu, where I setup an NSArray
with all identifiers for the UIViewController
which also have to be setup inside the UIStoryboard
:
When loading the menu, I loop through the NSArray
and load the UIViewControllers
by identifiers from the specific UIStoryboard
. This is the place where I needed to implement a switch, for the different UIStoryboards
:
self.arrayVCAll = [NSMutableArray new];
for ( NSArray *array in _arrayViewControllerAll ){
NSMutableArray *arrayTemp = [NSMutableArray new];
for (UIViewController *vc in array ){
NSString *strViewController = [NSString stringWithFormat:@"%@", vc];
UIStoryboard *storyboard;
if( [strViewController isEqualToString:@"CustomOneStoryboard"] ){
storyboard = [UIStoryboard storyboardWithName:@"FirstVC" bundle:nil];
} else if( [strViewController isEqualToString:@"CustomTwoStoryboard"] ){
storyboard = [UIStoryboard storyboardWithName:@"SecondVC" bundle:nil];
} else {
storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
}
UIViewController *controller = [storyboard instantiateViewControllerWithIdentifier:strViewController];
MyNavController *nav = [[MyNavController alloc] initWithRootViewController:controller];
[arrayTemp addObject:nav];
}
[self.arrayVCAll addObject:arrayTemp];
}
In my case, there was just a problem with the segues after separating the initial UINavigationController
from my UIViewControllers
. The segues won't push to a navigationController, if there is no initial UINavigationController
. Thats why I added a UINavigationController
on each UIViewController
(of my NSArray) so the UIStoryboardSegue
will be done correctly. The UINavigationController
also doesn't need to be connected to a class, just include it inside the UIStoryboard
and connect it to the first UIViewController
.