Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

scanf

macrumors newbie
Original poster
Apr 23, 2010
15
0
I'm trying to do something that is probably a bit unorthodox, but I have a UITabBarController that I want to add 4 tabs to, but all i want to do is capture the tab bar controller's selectedIndex inside of didSelectViewController and perform any needed actions on my own.

I don't need to hide or show any views, just load different urls into a webview i already have loaded. the problem is that i don't know how to add these tabs other than to set the viewControllers property. Is there any way to accomplish what I want?

Btw, I'm creating the UITabBarController programmatically
 
i have it kind of working thanks to this tutorial:
http://howtomakeiphoneapps.com/how-can-i-add-tabs-programmatically-to-uitabbar/201/

however, the UITabBarController seems to be acting modal as I now can't interact with the webview. here's my code. notice anything wrong?

Code:
	//set up main view controller
	mainViewController = [[MainViewController alloc] init];	
	[window addSubview:mainViewController.view];	
	
	
	//set up the tab bar controller
	NSMutableArray *listOfViewControllers = [[NSMutableArray alloc] init];
	UIViewController *vc;
	
	vc = [[UIViewController alloc] init];
	vc.title = @"A";
	[listOfViewControllers addObject:vc];
	[vc release];
	vc = [[UIViewController alloc] init];
	vc.title = @"B";
	[listOfViewControllers addObject:vc];
	[vc release];
	vc = [[UIViewController alloc] init];
	vc.title = @"C";
	[listOfViewControllers addObject:vc];
	[vc release];	
	
	window.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
	tabBarController = [[UITabBarController alloc] init];
    tabBarController.view.autoresizingMask =  UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    tabBarController.viewControllers = listOfViewControllers;
    [window addSubview:tabBarController.view];
    tabBarController.delegate = self;

is it because i'm adding both the mainviewcontroller and the tabbarcontroller as subviews to the window?
 
ok, the trick is to NOT use a UITabBarController, but instead a UITabBar.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.