[英]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. 在我的iPad应用程序中,我在底部有一个UITabBarController,其中有一堆视图控制器与一组标签相关联。 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.
我知道如何使用UIPopoverController,但我不知道如何在没有给标签栏控制器提供UIViewController的情况下将标签添加到UITabBarController。
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 如果你真的想这样做(它是非常非标准的UI ...),那么你可以添加一个空的视图控制器,但在你的标签栏中委托实现
- (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. 并为该视图控制器返回
NO
(因此它不会被选中),而是显示您的弹出窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.