如何从选项卡而不是视图中获得弹出窗口 [英] How can I have a popover come from a tab instead of a view
问题描述
我有一个标签栏应用,我想要一个标签来自其中一个标签。有没有一个好的/简单的方法来做到这一点而不改变观点?
I have a tabbar app, and I want a popover to come from one of the tabs. Is there a good/easy way to do this without changing views?
推荐答案
目前没有办法直接(通过支持的api调用)获取特定标签栏项的框架。我所做的只是显示标签栏左端的弹出窗口,如下所示:
There isn't currently a way to directly (through a supported api call) get the frame of a specific tab bar item. What I do is just show the popup from the left end of the tab bar like this:
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];
如果您确实考虑当前方向,可以尝试估算标签栏项目的位置想要并调整上面矩形的X坐标。
You could try to estimate the position of the tab bar item taking the current orientation into account if you really wanted to and adjust the X coordinate of the rect above.
您还可以查看标签栏的子视图并找到UITabBarButton对象,但是没有记录,所以不建议这样做。
You could also look through the subviews of the tabbar and find the UITabBarButton object but that's not documented so it's not recommended.
这篇关于如何从选项卡而不是视图中获得弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!