Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
631 views
in Technique[技术] by (71.8m points)

ipad - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...