title: How move up UITextField with keyboard if using Navigation Controller Swift
body: <p>I try move up UITextField, but does not work if use Navigation Controller, and <code>print(self.view.frame.origin.y)</code> write <code>-216</code></p>
  
  <p><a href="https://i.stack.imgur.com/Jviig.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jviig.png" alt="enter image description here"></a></p>
  
  <p>Everything works perfectly if you do not use Navigation Controller </p>
  
  <pre><code>class RegistratoinViewController: UIViewController, UITextFieldDelegate {
  
  @IBOutlet weak var nameTextField: UITextField!
  @IBOutlet weak var emailTextField: UITextField!
  @IBOutlet weak var passwordTextField: UITextField!
  @IBOutlet weak var confirmPasswordTextField: UITextField!
  
  var activeTextField: UITextField!
  
  override func viewDidLoad() {
      super.viewDidLoad()
      singUpButton.enabled = false
      self.hideKeyboardWhenTappedAround()
  
      self.nameTextField.delegate = self
      self.emailTextField.delegate = self
      self.passwordTextField.delegate = self
      self.confirmPasswordTextField.delegate = self
  
      self.nameTextField.keyboardAppearance = UIKeyboardAppearance.Dark
      self.emailTextField.keyboardAppearance = UIKeyboardAppearance.Dark
      self.passwordTextField.keyboardAppearance = UIKeyboardAppearance.Dark
      self.confirmPasswordTextField.keyboardAppearance = UIKeyboardAppearance.Dark
      self.emailTextField.keyboardType = UIKeyboardType.EmailAddress
      NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(RegistratoinViewController.keyboardWillShow(_:)), name:UIKeyboardWillShowNotification, object: self.view.window)
      NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(RegistratoinViewController.keyboardWillHide(_:)), name:UIKeyboardWillHideNotification, object: self.view.window)
  }
  
  func keyboardWillHide(sender: NSNotification) {
      let userInfo: [NSObject : AnyObject] = sender.userInfo!
      let keyboardSize: CGSize = userInfo[UIKeyboardFrameBeginUserInfoKey]!.CGRectValue.size
      self.view.frame.origin.y += keyboardSize.height
  }
  
  override func viewWillDisappear(animated: Bool) {
      NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillShowNotification, object: self.view.window)
      NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillHideNotification, object: self.view.window)
  }
  
  func keyboardWillShow(sender: NSNotification) {
      let userInfo: [NSObject : AnyObject] = sender.userInfo!
  
      let keyboardSize: CGSize = userInfo[UIKeyboardFrameBeginUserInfoKey]!.CGRectValue.size
      let offset: CGSize = userInfo[UIKeyboardFrameEndUserInfoKey]!.CGRectValue.size
  
      if keyboardSize.height == offset.height {
          if self.view.frame.origin.y == 0 {
              UIView.animateWithDuration(0.1, animations: { () -&gt; Void in
                  self.view.frame.origin.y -= keyboardSize.height
              })
          }
      } else {
          UIView.animateWithDuration(0.1, animations: { () -&gt; Void in
              self.view.frame.origin.y += keyboardSize.height - offset.height
          })
      }
      print(self.view.frame.origin.y)
  }
  </code></pre>
  
  <p>}</p>