title: Adjust View for keyboard appears when switching UITextField (Swift)
body: <p>I have two UIView's , the Main one and one which will move up when the keyboard appears (Second UIView  has two textfields). I've managed to do this with the following code:</p>
  
  <p>LoginViewController.swift :</p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
  
  
      self.originalCenter = self.contentView.center;
  NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardDidShow:", name: UIKeyboardDidShowNotification, object: nil)
  
  
  }
  
  func keyboardDidShow(notification: NSNotification)
  {
      UIView.animateWithDuration(1.0, animations: {
      self.contentView.center = CGPointMake(self.originalCenter.x, self.originalCenter.y - 40);
       })
  
  }
  </code></pre>
  
  <p>My big problems is that because the movement of the UIView depends on the keyboard notification, when the user taps one TextField it moves up as it should, but when he taps the second one the view moves down automatically. What Im I doing wrong?</p>
  
  <p>This is what is happening: <a href="http://zippy.gfycat.com/LankyThoseFieldspaniel.gif" rel="nofollow noreferrer">Keyboard Error Gif</a></p>
  
  <p>This question was answered <a href="https://stackoverflow.com/questions/15052964/adjust-view-for-keyboard-when-switching-uitextfield">over here</a> , but I need the solution for Swift language.</p>