title: Move a view up only when the keyboard covers an input field
body: <p>I am trying to build an input screen for the iPhone. The screen has a number of input fields. Most of them on the top of the screen, but two fields are at the bottom. 
  When the user tries to edit the text on the bottom of the screen, the keyboard will pop up and it will cover the screen. 
  I found a simple solution to move the screen up when this happens, but the result is that the screen <em>always</em> moves up and the fields on top of the screen move out of reach when the user tries to edit those. </p>
  
  <p>Is there a way to have the screen <em>only</em> move when the bottom fields are edited?</p>
  
  <p>I have used this code I found <a href="https://stackoverflow.com/questions/25693130/move-textfield-when-keyboard-appears-swift">here</a>: </p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()        
      NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillShow:"), name: UIKeyboardWillShowNotification, object: nil)
      NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide:"), name: UIKeyboardWillHideNotification, object: nil)
  }
  
  func keyboardWillShow(sender: NSNotification) {
      self.view.frame.origin.y -= 150
  }
  
  func keyboardWillHide(sender: NSNotification) {
      self.view.frame.origin.y += 150
  }
  </code></pre>