1

I had been using a line of code like this in my ios8 iphone app to help with laying out subviews relative to the navigation controller navigation bar:

height -= self.navigationController.navigationBar.frame.size.height;

But all my alignments of views were off vertically. I kept rechecking my algebra, but that wasn't the problem. Rather, the above line of code is getting the wrong value.

I did some reading (What is the height of Navigation Bar in iOS 7?) and found out that as of ios 7 the navigation bar is 64 points...but my line of code returns 44:

self.navigationController.navigationBar.frame.size.height

You might say my math is just wrong, but once I hard-coded 64 into my program rather than using the above line, everything works perfectly and all the layouts are exactly as they should be.

To make it more confusing, the call above does return 0 when there is no navigation bar present. So it's partly right. Is this a known bug or am I doing something stupid without knowing? If I were supposed to initialize something and didn't, I could understand a null or random value, but to get the old 44 value rather than the new 64 value seems buggy.

So to frame this as a question - did I do something wrong or is this a bug?

Thanks for any suggestions/info.

Community
  • 1
  • 1
  • navigationBar is 44 points, like toolbar. Status Bar is 20 points. In the header or your iPhone you have statusBar+navigationBar = 64. – Onik IV Nov 26 '14 at 21:28

0 Answers0