title: Resize the screen when keyboard appears
body: <p>I am building a chat app. I have to move a textfield when keyboard appears. I am doing this with the following code:</p>
  
  <pre><code>func keyboardWillShow(notification: NSNotification) {
      if let userInfo = notification.userInfo {
          if let keyboardSize =  (userInfo[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
              kbHeight = keyboardSize.height
              self.animateTextField(true)
          }
      }
  }
  func keyboardWillHide(notification: NSNotification) {
      self.animateTextField(false)
  }
  
  func animateTextField(up: Bool) {
      var movement = (up ? -kbHeight : kbHeight)
  
      UIView.animateWithDuration(0.3, animations: {
          self.view.frame = CGRectOffset(self.view.frame, 0, movement)
      })
  }
  </code></pre>
  
  <p>But when I use this code, the first messages doesn't show. I guess I have to resize the tableview.</p>
  
  <p>Here are screenshots <strong>Before</strong> and <strong>After</strong> the keyboard appears:</p>
  
  <p><a href="https://i.stack.imgur.com/Zx1GC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Zx1GC.png" width="200"/></a>
  
  <a href="https://i.stack.imgur.com/sbE0k.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sbE0k.png" width="200"/></a>
  </p>
  
  <p>I am using auto layout.</p>
  
  <p>How can I resolve this problem?</p>