title: Programmatically get height of navigation bar
body: <p>I know that the presence of the more view controller (navigation bar) pushes down the UIView by its height.  I also know that this height = 44px.  I have also discovered that this push down maintains the <code>[self.view].frame.origin.y = 0</code>.</p>
  
  <p>So how do I determine the height of this navigation bar, other than just setting it to a constant?</p>
  
  <p>Or, shorter version, how do I determine that my UIView is showing with the navigation bar on top?</p>
  
  <hr>
  
  <p>The light bulb started to come on. Unfortunately, I have not discovered a uniform way to correct the problem, as described below.</p>
  
  <p>I believe that my whole problem centers on my autoresizingMasks. And the reason I have concluded that is the same symptoms exist, with or without a UIWebView. And that symptom is that everything is peachy for Portrait. For Landscape, the bottom-most UIButton pops down behind the TabBar.</p>
  
  <p>For example, on one UIView, I have, from top to bottom:</p>
  
  <p>UIView – both springs set (default case) and no struts</p>
  
  <p>UIScrollView - If I set the two springs, and clear everything else (like the UIView), then the UIButton intrudes on the object immediately above it. If I clear everything, then UIButton is OK, but the stuff at the very top hides behind the StatusBar Setting only the top strut, the UIButton pops down behind the Tab Bar.</p>
  
  <p>UILabel and UIImage next vertically – top strut set, flexible everywhere else</p>
  
  <p>Just to complete the picture for the few that have a UIWebView:</p>
  
  <p>UIWebView - Struts: top, left, right Springs: both</p>
  
  <p>UIButton – nothing set, i.e., flexible everywhere</p>
  
  <p>Although my light bulb is dim, there appears to be hope.</p>
  
  <hr>
  
  <p>Please bear with me because I needed more room than that provided for a short reply comment.</p>
  
  <p>Thanks for trying to understand what I am really fishing for ... so here goes.</p>
  
  <p>1) Each UIViewController (a TabBar app) has a UIImage, some text and whatever on top. Another common denominator is a UIButton on the bottom. On some of the UIViewControllers I have a UIWebView above the UIButton.</p>
  
  <p>So, UIImage, text etc. UIWebView (on SOME) UIButton</p>
  
  <p>Surrounding all the above is a UIScrollView.</p>
  
  <p>2) For those that have a UIWebView, its autoresizingMask looks like:</p>
  
  <pre><code>   —
     |
     —
  
     ^
     |
     |
  </code></pre>
  
  <p>|—| ←----→ |—|
         |
         | 
         V
  The UIButton's mask has nothing set, i.e., flexible everywhere</p>
  
  <p>Within my -viewDidLoad, I call my -repositionSubViews within which I do the following:</p>
  
  <p>If there is no UIWebView, I do nothing except center the UIButton that I placed with IB.</p>
  
  <p>If I do have a UIWebView, then I determine its *content*Height and set its frame to enclose the entire content.</p>
  
  <pre><code>UIScrollView *scrollViewInsideWebView = [[webView_ subviews] lastObject];
  webViewContentHeight = scrollViewInsideWebView.contentSize.height;
  [webView_ setFrame:CGRectMake(webViewOriginX, webViewOriginY,
                            sameWholeViewScrollerWidth, webViewContentHeight)]
  </code></pre>
  
  <p>Once I do that, then I programmatically push the UIButton down so that it ends up placed below the UIWebView.</p>
  
  <p>Everything works, until I rotate it from Portrait to Landscape.</p>
  
  <p>I call my -repositionSubViews within my -didRotateFromInterfaceOrientation.</p>
  
  <p>Why does the content height of my UIWebView not change with rotation?.</p>
  
  <p>From Portrait to Landscape, the content width should expand and the content height should shrink. It does visually as it should, but not according to my NSLog.</p>
  
  <p>Anyway, with or without a UIWebView, the button I've talked about moves below the TabBar when in Landscape mode but it will not scroll up to be seen. I see it behind the TabBar when I scroll "vigorously", but then it "falls back" behind the TabBar.</p>
  
  <p>Bottom line, this last is the reason I've asked about the height of the TabBar and the NavigationBar because the TabBar plants itself at the bottom of the UIView and the NavigationBar pushes the UIView down.</p>
  
  <p>Now, I'm going to add a comment or two here because they wouldn't have made sense earlier.</p>
  
  <p>With no UIWebView, I leave everything as is as seen by IB.</p>
  
  <p>With a UIWebView, I increase the UIWebView's frame.height to its contentHeight and also adjust upward the height of the surrounding UIScrollView that surrounds all the sub-views.</p>
  
  <p>Well there you have it.</p>