Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a tab bar item to UITabBarController without a view controller?

In my iPad app, I have a UITabBarController at the bottom with a bunch of view controllers associated to a bunch of tabs. I would like to have a tab that shows a pop over when the tab is touched. I know how to use the UIPopoverController, but I don't know how to add a tab to a UITabBarController without giving the tab bar controller a UIViewController.

Any suggestions on how to do this?

Thanks.

Here is the code that I have to show the pop over. (Source)

CGFloat tabBarHeight = self.tabBarController.tabBar.bounds.size.height;
CGRect rect = CGRectMake(0, 0, tabBarHeight, tabBarHeight);
[popoverController presentPopoverFromRect:rect 
    inView:self.tabBarController.tabBar 
    permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
like image 809
David Avatar asked Aug 24 '11 18:08

David


1 Answers

If you really want to do this (it's pretty nonstandard UI...), then you could add an empty view controller, but in your tab bar delegate implement

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController

And return NO for that view controller (so it doesn't get selected) but instead show your popover.

like image 67
jtbandes Avatar answered Nov 08 '22 02:11

jtbandes