I am looking at rebuilding the settings section of my app using the new functionality provided by storyboards
. Not wanting to touch the rest of my app at this point, so my main NIB
will be staying.
Now when going from my NIB
'ed tabBar
to another NIB
I just add a viewController
to the tabBar
in IB and then set the NIB Name
property to the NIB
which I want to load when that tab is pressed.
But there is no 'storyboard name' property that I can see, so how is this done?
There is no "official" way to do it at the moment, but you can do it using some tricks.
1) add your view controller to your tabbar in nib in the usual way. Leave the nib field empty.
2) create your storyboard and add your viewcontroller. Set the class and set a storyboard ID (I'll use "theID" for this example)
3) add a static bool var to your .m file, outside implementation or interface
static BOOL aFlag = NO;
4) in your viewcontroller class override this method:
- (id) awakeAfterUsingCoder:(NSCoder *)aDecoder
{
if (!aFlag){
aFlag = YES;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
return [storyboard instantiateViewControllerWithIdentifier:@"theID"];
} else {
return self;
}
}
essentially:
I tried and it works good ;-) If you want here is an example project: http://www.lombax.it/files/testTabNib.zip