title: iOS 12 wrong navigation bar height
body: <p>I'm working on an iPad app in landscape orientation. There is a navigation bar at the top without a status bar, and I want to line up a <code>UITableView</code> such that the top of the table is at the same y coordinate as the bottom of the navigation bar. Naturally, I do the following in <code>viewDidLoad</code>:</p>
  
  <pre><code>MyTableView* table = [[MyTableView alloc] init];
  table.frame = CGRectMake(someX, navBar.frame.size.height, someWidth, someHeight);
  [self.view addSubview:table];
  </code></pre>
  
  <p>At this point, <code>navBar.frame.size.height</code> returns 44. This is strange, because when I run the app, I see that my table overlaps the bottom of the navigation bar by a few points. I do some investigation, and find out that the navigation bar is actually drawing with a height of 50 points.</p>
  
  <p>I try to think what could be wrong, and realize that perhaps I'm doing this too early in the view controller's lifecycle and the views haven't yet been laid out, so I override <code>viewWillAppear</code>, <code>viewDidAppear</code>, and <code>viewDidLayoutSubviews</code>, all of which report that the navigation bar's height is 44, even when it is clearly drawing with a height of 50.</p>
  
  <p>I thought perhaps there's something I simply don't know, so I setup a timer to run a block of code that would repeatedly print out the height of the navigation bar every second after <code>viewDidLoad</code> was called, which allows for any view controller behind-the-scenes setup to finish. Still, every time the timer triggers the print, the height is only 44.</p>
  
  <p>I took a look at interface builder, and even there, in the dimensions property window (second tab from right), it says the navigation bar has a height of 44. Yet on the screen in the view controller in interface builder, it is clearly drawing with a height of 50.</p>
  
  <p>My question is: why does the reported height not match the height the navigation bar draws at? I need the correct height to place my table in the right location.</p>
  
  <p>At this point I'm at a loss for what could possibly be the issue, save for the API simply being completely broken. The only solution I can think of is to just position the navigation bar at -3 and hardcode in a y value for my table view of 44, resulting in 3 points on the top and bottom of the navigation bar being covered up, which is super janky and I want to avoid it if at all possible.</p>
  
  <p>Now, I understand that autolayout is a thing and constraints exist, but I like to manually compute the frames of my views in code and never use constraints, and that is the realm that this question is in. Please don't give answers like "you're supposed to use constraints".</p>
  
  <p>Although I doubt it matters, I'm running iOS 12.0.1 on an iPad Air 2.</p>
  
  <hr>
  
  <p>My debugging:</p>
  
  <p>Below is an image of the top center portion of my screen. Each of the rectangles is simply a <code>UIView</code> with a background color set, a y coordinate of 0, a width of 50 points, and are spaced 50 points apart from each other (each starts where the previous one ends). The heights of each rectangle from left to right are: 44, 50, and 51. You can tell the navigation bar is drawing at a height of 50 points since the right rectangle is just barely taller than the navigation bar.</p>
  
  <p><a href="https://i.stack.imgur.com/za95m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/za95m.png" alt="nav bar height visualization"></a></p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>I should probably mention that this navigation bar is added to the view controller via being dragged and dropped into a view controller in the storyboard. I still do some frame shenanigans in <code>viewDidLoad</code>, but it's not being dynamically added to the view there.</p>
  
  <p>Another interesting thing of note: In interface builder, you know the dashed blue lines that help you line things up? Apparently, those align with the 44 point height instead of the 50 point height:</p>
  
  <p><a href="https://i.stack.imgur.com/CbUiW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CbUiW.png" alt="blue alignment dashes broken"></a></p>