简体   繁体   中英

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];

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM