Что ж, если вы хотите сделать это программно, то я бы предложил заменить каждый из ваших viewControllers в вашем UITabBar на UINavigationControllers, в которых находятся соответствующие контроллеры представления.
Итак, ваш старый код выглядит примерно так:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
UITabBarController *tbc = [[[UITabBarController alloc]init]autorelease];
[window addSubview:tbc.view];
UIViewController *mapVC = [[[UIViewController alloc] init]autorelease];
NSArray *tabViewControllerArray = [NSArray arrayWithObjects:self.mapVC, nil];
tbc.viewControllers = tabViewControllerArray;
}
Новый код должен быть:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
UITabBarController *tbc = [[[UITabBarController alloc]init]autorelease];
[window addSubview:tbc.view];
UIViewController *mapVC = [[[UIViewController alloc] init]autorelease];
// add the viewController to a UINavigationController
UINavigationController *mapNav = [[[UINavigationController alloc] initWithRootViewController:mapVC]autorelease];
// put the nav controller in the array instead
NSArray *tabViewControllerArray = [NSArray arrayWithObjects:mapNav, nil];
tbc.viewControllers = tabViewControllerArray;
// this code adds a right button to the mapBav navigationBar
// this uses a custom view, but you could use a standard UIBarButtonItem too
NSArray *items = [NSArray arrayWithObjects: [UIImage imageNamed:@"flag-icon.png"], nil];
UISegmentedControl *tableControl = [[[UISegmentedControl alloc] initWithItems:items]autorelease];
tableControl.segmentedControlStyle = UISegmentedControlStyleBar;
UIBarButtonItem *segmentBarItem = [[[UIBarButtonItem alloc] initWithCustomView:tableControl] autorelease];
self.navigationItem.rightBarButtonItem = segmentBarItem;
}