Duck
Duck

Reputation: 35953

iPhone - area available inside a UITabbarController

I have a viewController that is being loaded as a tab on a UITabBarController.

How do I know, inside the viewController class, how much area I have available to show this viewController. I ask this because this VC is also shown inside a popover on iPad, using a specific size. On iPhone, I like it to fill the whole area available for a tab content, that is the screen size less that tab size in the bottom.

How do I get the value of this area inside the VC when it is inside a UITabBarController?

thanks

Upvotes: 2

Views: 785

Answers (1)

nacho4d
nacho4d

Reputation: 45118

If there is no direct method for that then since UITabBarController is a subclass of UIViewController you can access its view size and get the difference of its tabBar frame size:

CGSize viewSize =  self.tabBarController.view.frame.size;
CGSize tabBarSize = self.tabBarController.tabBar.frame.size;
CGSize vcSize = CGSizeMake(viewSize.width, viewSize.height - tabBarSize.height);

Upvotes: 2

Related Questions