title: UITextField text jumps iOS 9
body: <p>Link for previous question:
  <a href="https://stackoverflow.com/questions/32765372/uitextfield-text-jumps">UITextField text jumps</a></p>
  
  <p>Briefly:
  I have <code>ViewController</code> with 2 <code>UITextField</code> elements. When loginField is firstResponder, after</p>
  
  <pre><code>self.passwordField.becomeFirstResponder()
  </code></pre>
  
  <p>text in login field jumps to the top left corner and back. And what's more strange: this glitch reproduces only first time, then you need recreate <code>ViewController</code> to observe this behavior</p>
  
  <p>Here is video of the glitch <a href="http://tinypic.com/player.php?v=6nsemw%3E&amp;s=8#.VgVb3cuqpHx" rel="nofollow noreferrer">http://tinypic.com/player.php?v=6nsemw%3E&amp;s=8#.VgVb3cuqpHx</a></p>
  
  <h1>I ended up with this (doesn't work for iOS 9):</h1>
  
  <pre><code>func textFieldShouldReturn(textField: UITextField) -&gt; Bool {
      if textField === self.loginField {
          self.loginField.resignFirstResponder()
          // Shitty workaround. Hi, Apple!
          self.loginField.setNeedsLayout()
          self.loginField.layoutIfNeeded()
  
          self.passwordField.becomeFirstResponder()
          return false
      }
  
      return true
  }
  </code></pre>
  
  <p>Is there anybody who has been stucked with this bug? Any suggestions?</p>
  
  <h1>Keyboard notifications handlers</h1>
  
  <p>My main view is UIScrollView, for which I change bottom space to superview, so user can scroll all the content even when keyboard is shown</p>
  
  <pre><code>func keyboardWillShow(notification : NSNotification) {
      let keyboardInfo = notification.userInfo!
      let keyboardFrame = keyboardInfo[UIKeyboardFrameEndUserInfoKey]!.CGRectValue
      let animDuration = keyboardInfo[UIKeyboardAnimationDurationUserInfoKey]!.doubleValue!
  
      UIView.animateWithDuration(animDuration, animations: {
          self.scrollViewBottom.constant = keyboardFrame.height
          self.view.layoutIfNeeded()
  
          let offsetY = CGRectGetMaxY(self.loginButton.frame) + 10 - self.scrollView.frame.height
          if offsetY &gt; 0 {
              self.scrollView.contentOffset = CGPointMake(0, offsetY)
          }
      })
  }
  
  func keyboardWillHide(notification : NSNotification) {
      self.scrollViewBottom.constant = 0
      self.view.layoutIfNeeded()
  }
  </code></pre>
  
  <p>As I discovered keyboard notifications in iOS7, 8 and 9 very differ. So, in iOS 9 notifications are sent while changing firstResponder even if keyboard will not Show/Hide. Also, when I change firstResponder with tapping on textField (not tapping Next on keyboard which is handled by my code), there is only KeyboardWillShow notification and no KeyboardWillHide. And as for me, userInfo has some trash frame values, here is log when changing first responder using next button (works ok, without glitches):</p>
  
  <blockquote>
    <p>2015-10-07 12:54:13.870 keyboardWillHide:
    [UIKeyboardFrameBeginUserInfoKey: NSRect: {{0, 352}, {320, 216}},
    UIKeyboardCenterBeginUserInfoKey: NSPoint: {160, 460},
    UIKeyboardFrameEndUserInfoKey: NSRect: {{0, 568}, {320, 216}},
    UIKeyboardCenterEndUserInfoKey: NSPoint: {160, 676},
    UIKeyboardAnimationDurationUserInfoKey: 0.25,
    UIKeyboardIsLocalUserInfoKey: 1, UIKeyboardBoundsUserInfoKey: NSRect:
    {{0, 0}, {320, 216}}, UIKeyboardAnimationCurveUserInfoKey: 7]
    2015-10-07 12:54:13.896 keyboardWillShow:
    [UIKeyboardFrameBeginUserInfoKey: NSRect: {{0, 352}, {320, 216}},
    UIKeyboardCenterBeginUserInfoKey: NSPoint: {160, 460},
    UIKeyboardFrameEndUserInfoKey: NSRect: {{0, 352}, {320, 216}},
    UIKeyboardCenterEndUserInfoKey: NSPoint: {160, 460},
    UIKeyboardAnimationDurationUserInfoKey: 0.25,
    UIKeyboardIsLocalUserInfoKey: 1, UIKeyboardBoundsUserInfoKey: NSRect:
    {{0, 0}, {320, 216}}, UIKeyboardAnimationCurveUserInfoKey: 7]</p>
  </blockquote>
  
  <p>And here is log when I tap on the second textField:</p>
  
  <blockquote>
    <p>2015-10-07 12:55:13.879
    keyboardWillShow:[UIKeyboardFrameBeginUserInfoKey: NSRect: {{0, 352},
    {320, 216}},     UIKeyboardCenterBeginUserInfoKey: NSPoint: {160,
    460},     UIKeyboardFrameEndUserInfoKey: NSRect: {{0, 352}, {320,
    216}},     UIKeyboardCenterEndUserInfoKey: NSPoint: {160, 460},<br>
    UIKeyboardAnimationDurationUserInfoKey: 0.25,
    UIKeyboardIsLocalUserInfoKey: 1, UIKeyboardBoundsUserInfoKey: NSRect:
    {{0, 0}, {320, 216}}, UIKeyboardAnimationCurveUserInfoKey: 7]</p>
  </blockquote>
  
  <h1>Resolution</h1>
  
  <p>I discovered that I have another Keyboard Controller that receives keyboard notifications and make some animations. That's where the problem lies</p>