UITabBarController Custom Issues with Controllers and Views

I am writing a custom UITabBarController so that I can fully control the appearance of the tab bar. Everything works for me, so I have an array of view controllers that it handles.

The controller has a main view that fills the screen and inside it has a UIView at the bottom of the tab bar. This tab bar view has a button for each view controller. When the buttons are clicked, I add the view of the view manager to the main view and set it so that it does not show the view of the tab bar:

controller.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - kTabBarHeight);

      

This all works great and I can easily switch between view controllers. However, when I present a modal view controller and then dismiss it, the controller controller's current view becomes fullscreen and closes the tab bar! I tried to set the autoresist masks to not resize but keeps happening.

I also tried to add a view of view controllers to the bottom (below the tab bar) using:

[self.view insertSubview:controller.view atIndex:0];

      

But when I do this, the tab bar is even visible above any modal views! Which is strange. I think I am missing something in there, so I would appreciate if someone can explain what I am missing!

Thank,

Mike

+2


source to share


3 answers


I managed to find a better way to control the appearance of the tab bar by simply inserting subviews at the top of the tab bar with tab controllers. It worked!



+2


source


Try to install

controller.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - kTabBarHeight); 

      



in controller view WillAppear

+2


source


Try it. I think you need dynamic view controllers in the tab bar controller.

-(void)applicationDidFinishLaunching:(UIApplication *)application {

// Add the tab bar controller current view as a subview of the window
tabBarController.delegate=self;
tabBarController=[[UITabBarController alloc] init];

mainDashBoard=[[DashBoard alloc] initWithNibName:@"DashBoard" bundle:nil];
mainSearchView=[[SearchView alloc] initWithNibName:@"SearchView" bundle:nil];
mainMoreView=[[MoreView alloc] initWithNibName:@"MoreView" bundle:nil];

UINavigationController *nvCtr0=[[[UINavigationController alloc] init] autorelease];
UINavigationController *nvCtr1=[[[UINavigationController alloc] initWithRootViewController:mainDashBoard] autorelease];
UINavigationController *nvCtr2=[[[UINavigationController alloc] initWithRootViewController:mainSearchView] autorelease];
UINavigationController *nvCtr3=[[[UINavigationController alloc] initWithRootViewController:mainMoreView] autorelease];
UINavigationController *nvCtr4=[[[UINavigationController alloc] init] autorelease];//[[[UINavigationController alloc] initWithRootViewController:nil] autorelease];

tabBarController.viewControllers=[NSArray arrayWithObjects:nvCtr0,nvCtr1,nvCtr2,nvCtr3,nvCtr4,nil];

nvCtr0.tabBarItem.enabled=NO;
nvCtr4.tabBarItem.enabled=NO;

[window tabBarController.view];
}

      

+2


source







All Articles