tags:

views:

78

answers:

2
CGRect fullWindowRect = [UIScreen mainScreen].applicationFrame;

is an easy way to get the available rect, minus the status bar. With iPad/iPhones increasingly diverging in these basic system metrics I want to stop subtracting 44 to get the screen height when a UINavigationBar is in place. It is important for positioning things so that they are offset from the bottom of the screen by their own height, i.e. aligned with screen bottom.

What's the magic function, surely you are not just supposed to make consts for the two (or more) possible nav bar heights and remember when to apply them? I'm not finding answers here or elsewhere but I find "44" very often.

+1  A: 
CGFloat navHeight = navController.navigationBarHidden ? 0 :
    navController.navigationBar.frame.size.height;
drawnonward
Thanks - I had actually tried something like that (and failed) but now realize it was the right thing to do, only I can't get the height of the navigation bar before I actually create it :#
Adam Eberbach
A: 

Never use that hardcode such as '44', since it's not follow 'compatibility rule'. Nobody knows next generation's iPhone will have what kind of a 'status bar'.

except calculate the exact height of status bar or navigation bar, you can use something like:

[[UIScreen mainScreen] bounds]; 
[[UIScreen mainScreen] applicationFrame];
Elliot Chen