views:

77

answers:

1

I'm writing an app that uses UITabBar for parts of the navigation. I'm also using UIScrollView for presenting more information than what the screen can typically handle. Because of this, I'm needing to set the scroll view to take into account the height of the UITabBar so that all of the information is displayed.

Is there a way to calculate the height of the UITabBar?

Thanks, Matt

+1  A: 

It is 320 x 49.

If you want to test, open Interface Builder, add a UITabBar, go into the ruler, you will see it

UITabBar is inherited from UIVIew so you can use the frame.size.height to get the height

vodkhang
Is it guaranteed to stay that way for all time? I would rather use the API to get the value than rely on using IB and inserting magic numbers into the app.
Matt Delves
UITabBar is inherited from UIView, so you may try with frame.size.height of UIView
vodkhang
Will give that a shot when I get back from work. Do you know if I can get that without creating an instance of an object? Further, would it be better to create a dummy instance or to pass the in use UITabBar from the application delegate to the view I'm using so that it has a more accurate value?
Matt Delves
When I use IB, I can not change the height of the UITabBar, so I think it would be fixed. If you want to use API, there is no class method for that:(
vodkhang
Many thanks. Still to be verified, but enough information to resolve the issue.
Matt Delves
Assuming that your app delegate has a tab bar controller variable tabBarController the height can be accessed by((YouAppDelegate *)UIApplication.sharedApplication.delegate).tabBarController.tabBar.frame.size.height
Matt Delves