How can I get a popover from a tab instead of a view

I have a tab application and I want the popover to appear from one of the tabs. Is there a good / easy way to do this without changing the views?

+1
source share
1 answer

There is currently no way to directly (via a supported api call) get the frame of a specific tab bar item. I just show a popup from the left end of the tab bar as follows:

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 can try to estimate the position of the tab bar item taking into account the current orientation if you really wanted and adjusted the X coordinate of the rectangle above.

You can also look at the tab sub-items and find the UITabBarButton object, but this is not documented so that it is not recommended.

+4
source

Source: https://habr.com/ru/post/895788/


All Articles