title: Cannot close the gap between UIWebView and a UINavigationBar
body: <p>In my project I put a <code>UIWebView</code> under <code>UINavigationBar</code> and the setup the <code>UIWebView</code> to occupy the rest of the screen other than <code>UINavigationBar</code>. But I found some gaps between the two controls. There is also a gap between the left edge and the <code>UIWebView</code> left side. Any idea what I am missing?</p>
  
  <p><img src="https://i.stack.imgur.com/KN4GN.png" alt="enter image description here"></p>
  
  <p>Here is my updated code:
  in <code>UIView+AutoLayout</code>: (this category will set all the view's <code>translatesAutoresizingMaskIntoConstraints</code> property to <code>NO</code>)</p>
  
  <pre><code>#import "UIView+AutoLayout.h"
  
  @implementation UIView (AutoLayout)
  + (id)autolayoutView
  {
      UIView *view = [self new];
      view.translatesAutoresizingMaskIntoConstraints = NO;
      return view;
  }
  @end
  </code></pre>
  
  <p>in ViewController:</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      self.navigationBar = [UINavigationBar autolayoutView];
      UINavigationItem *backToListItem = [[UINavigationItem alloc] init];
      UIBarButtonItem *listItem = [[UIBarButtonItem alloc] initWithTitle:@"List"   style:UIBarButtonItemStylePlain target:self action:@selector(listButtonPressed:)];
      backToListItem.leftBarButtonItem = listItem;
  
      self.navigationBar.items = [NSArray arrayWithObject:backToListItem];
  
      [self.view addSubview:self.navigationBar];
  
      self.webView = [TNSWebView autolayoutView];
  
      [self.view addSubview:self.webView];
  
      NSDictionary *views = NSDictionaryOfVariableBindings(_navigationBar, _webView);
      [self.view addConstraints:[NSLayoutConstraint
                             constraintsWithVisualFormat:@"|[_navigationBar]|"
                             options:0 metrics:nil
                             views:views]];
      [self.view addConstraints:[NSLayoutConstraint
                                   constraintsWithVisualFormat:@"V:|[_navigationBar]-&gt;=0-[_webView]|"
                                   options:0 metrics:nil
                                   views:views]];
      [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_webView]|" options:0 metrics:nil views:views]];
      [self.webView setupVideoPlayer:self.videoId];
  }
  </code></pre>
  
  <p>Using the <code>po [[UIWindow keyWindow] recursiveDescription]</code> command in <code>lldb</code> I got this result</p>
  
  <pre><code>    | &lt;UIView: 0x1d23f880; frame = (0 20; 768 1004); autoresize = RM+BM; layer = &lt;CALayer: 0x1d23cba0&gt;&gt;
     |    | &lt;UINavigationBar: 0x1d00a4b0; frame = (0 0; 768 44); gestureRecognizers = &lt;NSArray: 0x1d015ff0&gt;; layer = &lt;CALayer: 0x1d0c8f60&gt;&gt;
     |    |    | &lt;_UINavigationBarBackground: 0x1d010250; frame = (0 0; 768 44); opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1d011140&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x1d0d26b0; frame = (0 44; 768 3); opaque = NO; autoresize = W+TM; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1d23fbd0&gt;&gt;
     |    |    | &lt;UINavigationItemView: 0x1d016740; frame = (384 22; 0 0); opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1d016840&gt;&gt;
     |    |    | &lt;UINavigationButton: 0x1d013ff0; frame = (7 7; 48 30); opaque = NO; layer = &lt;CALayer: 0x1d014170&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x1c5d9ca0; frame = (0 0; 48 30); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1c58b330&gt;&gt;
     |    |    |    | &lt;UIButtonLabel: 0x1d0144c0; frame = (13 7; 22 15); text = 'List'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1d014560&gt;&gt;
     |    | &lt;TNSWebView: 0x1d016bc0; baseClass = UIWebView; frame = (0 44; 768 960); layer = &lt;CALayer: 0x1d016ca0&gt;&gt;
     |    |    | &lt;_UIWebViewScrollView: 0x1d012390; frame = (0 0; 768 960); clipsToBounds = YES; autoresize = H; gestureRecognizers = &lt;NSArray: 0x1d011380&gt;; layer = &lt;CALayer: 0x1d0125e0&gt;; contentOffset: {0, 0}&gt;
     |    |    |    | &lt;UIImageView: 0x1d00f2a0; frame = (0 0; 10 10); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1d00f300&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x1d00f210; frame = (0 0; 10 10); transform = [0, 1, -1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1d00f270&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x1d00f180; frame = (0 0; 10 10); transform = [0, -1, 1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1d00f1e0&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x1d00efb0; frame = (0 0; 10 10); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1d00f150&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x1d00ef20; frame = (-4.5 4.5; 10 1); transform = [0, 1, -1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1d00ef80&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x1d00ee90; frame = (-4.5 4.5; 10 1); transform = [0, -1, 1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1d00eef0&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x1d00ee00; frame = (0 0; 1 10); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1d00ee60&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x1d00ec30; frame = (0 0; 1 10); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1d00edd0&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x1d00eba0; frame = (0 954; 768 6); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1d00ec00&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x1d00fcd0; frame = (0 0; 768 6); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1d00fe70&gt;&gt;
     |    |    |    | &lt;UIWebBrowserView: 0x1dbf2400; frame = (0 0; 768 960); gestureRecognizers = &lt;NSArray: 0x1d014c40&gt;; layer = &lt;UIWebLayer: 0x1d017d00&gt;&gt;
     |    |    |    |    | &lt;TileHostLayer: 0x1d017e70&gt; (layer)
     |    |    |    |    |    | &lt;TileLayer: 0x1c5511a0&gt; (layer)
     |    |    |    |    |    | &lt;TileLayer: 0x1c551210&gt; (layer)
     |    |    |    |    |    | &lt;TileLayer: 0x1c551250&gt; (layer)
     |    |    |    |    |    | &lt;TileLayer: 0x1c551290&gt; (layer)
  </code></pre>
  
  <p>The updated screenshot:</p>
  
  <p><img src="https://i.stack.imgur.com/YELMs.jpg" alt="enter image description here"></p>
  
  <p>By just changing the height of the navigationbar to 44 and use recursiveDescription command I got:</p>
  
  <pre><code>$0 = 0x2008f680 &lt;UIWindow: 0x1ed814f0; frame = (0 0; 768 1024); autoresize = W+H; layer = &lt;UIWindowLayer: 0x1ed815f0&gt;&gt;
     | &lt;UIView: 0x20167680; frame = (0 20; 768 1004); autoresize = RM+BM; layer = &lt;CALayer: 0x1ed0ea50&gt;&gt;
     |    | &lt;UINavigationBar: 0x1ed14b70; frame = (0 0; 768 44); gestureRecognizers = &lt;NSArray: 0x20081bd0&gt;; layer = &lt;CALayer: 0x1ed09ff0&gt;&gt;
     |    |    | &lt;_UINavigationBarBackground: 0x1ed8b9b0; frame = (0 0; 768 44); opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x1ed08570&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x2007aa90; frame = (0 44; 768 3); opaque = NO; autoresize = W+TM; userInteractionEnabled = NO; layer = &lt;CALayer: 0x200f9640&gt;&gt;
     |    |    | &lt;UINavigationItemView: 0x20053320; frame = (384 22; 0 0); opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x200f9c30&gt;&gt;
     |    |    | &lt;UINavigationButton: 0x200fa980; frame = (7 7; 48 30); opaque = NO; layer = &lt;CALayer: 0x200f50c0&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x2016af20; frame = (0 0; 48 30); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x2016af80&gt;&gt;
     |    |    |    | &lt;UIButtonLabel: 0x2004e420; frame = (13 7; 22 15); text = 'List'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x200f8040&gt;&gt;
     |    | &lt;TNSWebView: 0x2004d660; baseClass = UIWebView; frame = (0 44; 768 960); layer = &lt;CALayer: 0x20053f20&gt;&gt;
     |    |    | &lt;_UIWebViewScrollView: 0x2004a230; frame = (0 0; 768 960); clipsToBounds = YES; autoresize = H; gestureRecognizers = &lt;NSArray: 0x20049700&gt;; layer = &lt;CALayer: 0x2004a6c0&gt;; contentOffset: {0, 0}&gt;
     |    |    |    | &lt;UIImageView: 0x20048d50; frame = (0 0; 10 10); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x20048db0&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x20048cc0; frame = (0 0; 10 10); transform = [0, 1, -1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x20048d20&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x20048c30; frame = (0 0; 10 10); transform = [0, -1, 1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x20048c90&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x200f7c50; frame = (0 0; 10 10); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x20048c00&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x200f7bc0; frame = (-4.5 4.5; 10 1); transform = [0, 1, -1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x200f7c20&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x200f7b30; frame = (-4.5 4.5; 10 1); transform = [0, -1, 1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x200f7b90&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x200f7a30; frame = (0 0; 1 10); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x200f7b00&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x200f7890; frame = (0 0; 1 10); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x200f7a00&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x200fad20; frame = (0 954; 768 6); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x200fad80&gt;&gt;
     |    |    |    | &lt;UIImageView: 0x200fab80; frame = (0 0; 768 6); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0x200facf0&gt;&gt;
     |    |    |    | &lt;UIWebBrowserView: 0x1fb37600; frame = (0 0; 768 960); gestureRecognizers = &lt;NSArray: 0x20049910&gt;; layer = &lt;UIWebLayer: 0x200f81c0&gt;&gt;
     |    |    |    |    | &lt;TileHostLayer: 0x2004ed10&gt; (layer)
     |    |    |    |    |    | &lt;TileLayer: 0x20168820&gt; (layer)
     |    |    |    |    |    | &lt;TileLayer: 0x20168890&gt; (layer)
     |    |    |    |    |    | &lt;TileLayer: 0x201688d0&gt; (layer)
     |    |    |    |    |    | &lt;TileLayer: 0x20168910&gt; (layer)
  </code></pre>