Reputation: 21
Background: The app's UI is a tab bar controller, with each tab bar having its own navigation controller. Several view controllers are common, the user may access them reguardless of which tab they they are using. Initially I simply had segues from all over the storyboard going to one view controller on the storyboard for these common views. But I realized the user could get to the common view, select a different tab, and get back to that common view on a different navigation controller...and I didn't know what that ment. Were these two different instantiations of the view controller? If not, which navigation controller would it go "back" on when popped?
Xcode crashes became more and more frequent until it began crashing immediately upon opening storyboard. At the same time I had dozens of "ambiguous view" type warnings that I had been putting off resolving. So I tweaked the constraints until all the warnings were eliminated plus I eliminated any segues between navigation controllers, I just had multiple copies of the common views. And Xcode has been stable as a rock since. But now I have three copies each of a whole group of my view controllers in my storyboard, and changing/maintaining them is proving cumbersome.
Upvotes: 2
Views: 960
Reputation: 1733
What you can do is just duplicate the viewcontroller you like to have multiple segues to in your storyboard. In the viewDidLoad of your viewcontroller you can find out from which tab you were called with, and possibly adapt it's function:
UITabBarController *tabBarController = (UITabBarController *)[[UIApplication sharedApplication] delegate].window.rootViewController;
ALog( @"Selected tab: %d", tabBarController.selectedIndex );
This simply askes the application's UITabBarController which is the selected tab.
So, this is not more segues to one viewcontroller, but it may be close enough for practical purposes.
Upvotes: 1
Reputation: 119031
Storyboard is quite powerful, but it is also a convenience and, arguably, designed for simple interfaces and more novice programmers. So, when creating more complex (or, more aptly, less standard) interfaces you want to move more into code. This could be a combination of named view controllers in your storyboard (instantiated from code) or standalone XIB files.
Upvotes: 3