简体   繁体   English

如何在没有视图控制器的情况下将标签栏项添加到UITabBarController?

[英]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.

相关问题 将控制器添加到UITabBarController,而标签栏中没有出现新项目 - Add controller to UITabBarController without new item appearing in the tab bar UITabBarController添加不带标签栏项目的viewcontroller - UITabBarController add viewcontroller without tab bar item 来自UITabBarController的当前视图控制器,未显示选项卡栏 - Present view controller from UITabBarController without tab bar showing 如何使用标签栏项添加导航栏以查看控制器 - How to add Navigation bar to view controller with tab bar item 没有 TabBarController 的标签栏 - 在故事板中为标签栏项目添加视图控制器 - Tab bar without TabBarController - add View Controller for Tab bar item in storyboard 没有标签栏项目的UITabBarController中的UIViewController - UIViewController in a UITabBarController without tab bar item 共享按钮作为 UITabBarController 上的标签栏项目,没有关联的控制器 - share button as tab bar item on UITabBarController with no controller associated 当推入我的UITabBarController时,视图控制器隐藏的选项卡栏 - Tab bar hidden by view controller when pushed inside my UITabBarController UITabBarController:标签栏涵盖视图 - UITabBarController: Tab bar covers view 将UINavigationController添加到UITabBarController,而不显示所有视图中的Tab Bar - Add UINavigationController to UITabBarController without Tab Bar showing up in all views
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM