First, in your Storyboard, make a relationship between your UITabBarController and a UINavigationController (we will be using the same UINavigationController for the fourth bar item regardless if the user has our specialProperty
). Make the rootViewController of the UINavigationController be the custom UIViewController that presets your UIWebView (you can hide the navigation bar in your storyboard if you choose).
Then, make a custom subclass of UITabBarController if you have not done so already and set your UITabBarController in your storyboard to use this class (in my example, we will call this class MyTabBarController). You will need to override prepareSegue:sender:
in this class.
For example:
@interface MyTabBarController : UITabBarController
@end
@implementation MyTabBarController
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// get destination UIViewController
id controller = segue.destinationViewController;
// check if the destination has a rootViewController property
if ([controller respondsToSelector:@selector(setRootViewController:)]) {
// check your special property
if ([controller specialProperty]) {
// init the root of your UINavigationController
UIViewController *specialController = [[MySpecialViewController alloc] init];
[controller setRootViewController:specialController];
// if you are not using ARC, call [specialController release] here
// if you hid the navigation bar for your default controller in storyboard, show it
[controller setNavigationBarHidden:NO animated:NO];
} else {
// do some custom configuration of your controller without the special property
}
} else {
NSLog(@"%@ does not have a root view controller to override.",controller);
}
}
@end