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 c开发者_StackOverflow社区ontrollers 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.
精彩评论