UITabBar Programatically
Hi,
I have a slight issue thats been bugging me today.
I have this tabBar that i declared. Everything is fine but the navigation bar when it appears, its coming on half the screen.. I want it like the normal navigation bar on top where it should be.
Here's the code.
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
//create the main view
UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.backgroundColor = [UIColor darkGrayColor];
self.view = contentView;
[contentView release];
//add the Navigation Controller and add the FirstView as the Root View
UINavigationController *localNavigationController;
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:4];
//add the tab-bar
UITabBarController *tabBarController;
tabBarController = [[UITabBarController alloc]init];
// define a custom frame size for the entire tab bar controller that will be in the
// bottom half of the screen.
CGRect tabBarFrame;
tabBarFrame = CGRectMake(0, 240, 320, 200);
tabBarController.view.frame = tabBarFrame;
//set-up the First View Controller
SmartDialer *firstView;
firstView = [[SmartDialer alloc] initWithTabBar];
localNavigationController = [[UINavigationController alloc] initWithRootViewController:firstView];
// add the new nav controller (with the root view controller inside it)
// to the array of controllers
[localControllersArray addObject:localNavigationController];
// release since we are done with this for now
[localNavigationController release];
[firstView release];
// set-up the SecondView Controller
IDCalls *secondView;
secondView = [[IDCalls alloc] initWithTabBar];
localNavigationController = [[UINavigationController alloc] initWithRootViewController:secondView];
[localControllersArray addObject:localNavigationController];
[localNavigationController release];
[secondView release];
// set-up the ThirdView Controller
Reverselookup *thirdView;
thirdView = [[Reverselookup alloc] initWithTabBar];
localNavigationController = [[UINavigationController alloc] initWithRootViewController:thirdView];
[localControllersArray addObject:localNavigationController];
[localNavigationController release];
[thirdView release];
// set-up the FourthView Controller
UpcomingBdays *fourthView;
fourthView = [[UpcomingBdays alloc] initWithTabBar];
localNavigationController = [[UINavigationController alloc] initWithRootViewController:fourthView];
[localControllersArray addObject:localNavigationController];
[localNavigationController release];
[fourthView release];
// load up our tab bar controller with the view controllers
tabBarController.viewControllers = localControllersArray;
[localControllersArray release];
[self.view addSubview:tabBarController.view];
}
Please suggest...
|