I solved this myself by creating my own container UIViewController to mimic the tab bar
//
// UITabBarController.h
//
#import <UIKit/UIKit.h>
@interface UITabBarController : UIViewController
{
NSMutableArray *viewcontrollers;
int currentViewIndex;
}
@property(nonatomic) int selectedIndex;
- (id)initWithViewControllers:(NSArray *)viewControllers;
@end
//
// UITabBarController.m
//
#import "UITabBarController.h"
@implementation UITabBarController
- (id)initWithViewControllers:(NSArray *)viewControllers
{
if (self = [super init])
{
viewcontrollers = [[NSMutableArray alloc] init];
int count = [viewControllers count];
for(int i=0; i<count; i++)
{
UIViewController *vc = [viewControllers objectAtIndex:i];
[viewcontrollers addObject:vc];
}
currentViewIndex = 0;
[self setSelectedIndex:0];
}
return self;
}
- (void) setSelectedIndex:(int)index
{
// removing current view
UIViewController *viewcontroller = [viewcontrollers objectAtIndex:currentViewIndex];
[viewcontroller viewWillDisappear:NO];
[viewcontroller.view removeFromSuperview];
[viewcontroller viewDidDisappear:NO];
// adding new view
currentViewIndex = index;
viewcontroller = [viewcontrollers objectAtIndex:currentViewIndex];
[viewcontroller viewWillAppear:NO];
[self.view addSubview:viewcontroller.view];
[viewcontroller viewDidAppear:NO];
}
- (int) selectedIndex
{
return currentViewIndex;
}
- (void)dealloc
{
[viewcontrollers dealloc];
[super dealloc];
}
@end