title: Resize view when another view is hidden
body: <p>I have a <code>tableView</code> and a <code>iAd banner</code> beneath the <code>tableView</code>.</p>
  
  <p><strong>Goal</strong></p>
  
  <p>I'm trying to make the <code>tableViews</code> height get larger  when the <code>banner</code> is unable to receive ads. And when it can get ads, the <code>tableViews</code> height should shrink. (I would like to have animation if possible.)</p>
  
  <p><strong>Problem</strong></p>
  
  <p>When I run the app the <code>banner</code> is hidden initially (see code below), and the 
  <code>tableViews</code> height is as if there's a <code>banner</code>. Meaning it has the space on the bottom. Then when the <code>banner</code> appears, the <code>tableViews</code> height becomes even smaller and it has the space for 2 <code>banners</code>.</p>
  
  <p>(If this isn't clear please let me know and I'll post an image.)</p>
  
  <p>Here's the constraints:</p>
  
  <p>UITableView:<br>
  <a href="https://i.stack.imgur.com/xD8PH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xD8PH.jpg" alt="enter image description here"></a></p>
  
  <p>iAd Banner:<br>
  <a href="https://i.stack.imgur.com/zdfoR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zdfoR.jpg" alt="enter image description here"></a></p>
  
  <p>Here's the code:</p>
  
  <pre><code>func bannerViewDidLoadAd(banner: ADBannerView!) {
      self.bottomAddView?.hidden = false
  }
  
  func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
      self.bottomAddView?.hidden = true
  }
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>I tried adding a <code>height constraint</code> to the <code>ad banner</code>, and when I run the app, I get the following error:</p>
  
  <pre><code> Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[&lt;myAPp.MainViewController 0x7f9bd1d213b0&gt; setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key bottomAddView.'
  *** First throw call stack:
  (
      0   CoreFoundation                      0x000000011048ac65 __exceptionPreprocess + 165
      1   libobjc.A.dylib                     0x0000000110123bb7 objc_exception_throw + 45
      2   CoreFoundation                      0x000000011048a8a9 -[NSException raise] + 9
      3   Foundation                          0x000000010fcb9b53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
      4   CoreFoundation                      0x00000001103d2d50 -[NSArray makeObjectsPerformSelector:] + 224
      5   UIKit                               0x0000000110d0752b -[UINib instantiateWithOwner:options:] + 1506
      6   UIKit                               0x0000000110b5f718 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
      7   UIKit                               0x0000000110b5fd08 -[UIViewController loadView] + 109
      8   UIKit                               0x0000000110b5ff79 -[UIViewController loadViewIfRequired] + 75
      9   UIKit                               0x0000000110b9001b -[UINavigationController _layoutViewController:] + 44
      10  UIKit                               0x0000000110b90565 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 216
      11  UIKit                               0x0000000110b90664 -[UINavigationController _startTransition:fromViewController:toViewController:] + 92
      12  UIKit                               0x0000000110b91448 -[UINavigationController _startDeferredTransitionIfNeeded:] + 523
      13  UIKit                               0x0000000110b91f0e -[UINavigationController __viewWillLayoutSubviews] + 43
      14  UIKit                               0x0000000110cdc715 -[UILayoutContainerView layoutSubviews] + 202
      15  UIKit                               0x0000000110aafa2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
      16  QuartzCore                          0x000000011275dec2 -[CALayer layoutSublayers] + 146
      17  QuartzCore                          0x00000001127526d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
      18  QuartzCore                          0x0000000112752546 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
      19  QuartzCore                          0x00000001126be886 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
      20  QuartzCore                          0x00000001126bfa3a _ZN2CA11Transaction6commitEv + 462
      21  UIKit                               0x0000000110a2da2d -[UIApplication _reportMainSceneUpdateFinished:] + 44
      22  UIKit                               0x0000000110a2e6f1 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2648
      23  UIKit                               0x0000000110a2d0d5 -[UIApplication workspaceDidEndTransaction:] + 179
      24  FrontBoardServices                  0x000000011771d5e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
      25  CoreFoundation                      0x00000001103be41c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
      26  CoreFoundation                      0x00000001103b4165 __CFRunLoopDoBlocks + 341
      27  CoreFoundation                      0x00000001103b3947 __CFRunLoopRun + 887
      28  CoreFoundation                      0x00000001103b3366 CFRunLoopRunSpecific + 470
      29  UIKit                               0x0000000110a2cb42 -[UIApplication _run] + 413
      30  UIKit                               0x0000000110a2f900 UIApplicationMain + 1282
      31  myApp                             0x000000010f9b3207 main + 135
      32  libdyld.dylib                       0x0000000112f82145 start + 1
      33  ???                                 0x0000000000000001 0x0 + 1
  )
  libc++abi.dylib: terminating with uncaught exception of type NSException
  </code></pre>