Using a subset of the storyboard for the second purpose

I am going to develop a full version, a light version and a free version of the application. (or two of them at least)

In the past, without Storyboard, I just added a different target and set a compiler variable and used # if / else / endif statements to manage deviations between versions. Everything is fine so far.

This time I used a storyboard for the first time. It has about 50 controllers. And now I am faced with the question of how to deal with it. Moreover, the full application is a tab bar, and the light version should come without a tab bar (it will cover no more than the functionality corresponding to one of the tabs of the full version).

How can I handle this? Do I need a second storyboard? Will I be able to reuse the views from storyboard # 1 in storyboard # 2 and # 3? Or can I at least use the second storyboard just as a starting point and then move on to parts of storyboard # 1? (Again, the Lite app will be composed mostly of functionality, which is found in one of the tabs of the full app.)

To be honest, I don't even know where to start. This is why I cannot share what I have tried so far. Any hints are appreciated.

+3


source to share


1 answer


Ok I finally found a suitable path. While I'm not entirely happy with this one because it isn't what I was looking for, it works and it gives me a high degree of reuse.

1) Create a new target in xcode.

2) Xcode will create a second set of storyboards.

3) Storyboards have by default the same names as the original ones, but are in different (newly created by xcode) and assigned one for each target. I renamed it because I need both storyboards in my second target .. Renaming is not required if each target only uses its own storyboard. But in this case, you have to rename it. If you rename it, you need to assign a new name in the target project settings. Works beautifully.

4) In my case, the storyboard for the free app basically consists of its root view controller and one regluar view controller, which perceives me as some sort of main menu for the user. In my case, the full app is tab-based and due to limited functionality, and in some of the more meager use cases, there is no free app.

5) This main menu controller will then programmatically display the controllers of another story panel. For this, it is important that all identifiers in the storyboard are correctly set and unique (!). In my case, this menu consists of several buttons. Each of them calls IBAction. You could, of course, use a table instead.

 - (IBAction)newMinutes:(id)sender
 {
     // Get the storyboard named secondStoryBoard from the main bundle:
     UIStoryboard *secondStoryBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];

     // Load the view controller with its identifier string 
     // Change UIViewController to the appropriate class
     UIViewController *theTabBar = (UIViewController *)[secondStoryBoard instantiateViewControllerWithIdentifier:@"MinutesMenu"];

     // Then push the new view controller in the usual way:
     [self.navigationController pushViewController:theTabBar animated:YES];
 }

      



6) Once this view controller is up and running, it works fine in its own storyboard and will navigate fine to subsequent view controllers, etc.

7) However, in some place I still need to do some deviations. For these situations, I set up two macros in each setting of the target project. FREE

and FULL

are these macros. Therefore, I can compile slightly different code, such as a program segment, using the construct #ifdef

.

#ifdef FULL 
  // do this
#else 
  // do that
#endif

      

or

#ifdef FREE
  // do this
#endif

      

Hope this helps TJ and others in the same situation.

+2


source







All Articles