title: Scroll to the very bottom of UIScrollView when Keyboard appears (AutoLayout)
body: <p>I am trying to scroll to the bottom content of the UIScrollView when the keyboard is shown, but the method setContentOffset doesnt seem to work. I am using AutoLayout on Interface Builder. Perhaps this is what causes the problem? Any thoughts?</p>
  
  <p>How could I scroll to the bottom of my UIScrollView when my the keyboard is shown.</p>
  
  <p>P.S.: It will show the textField just fine, <em>what I need is to show the very bottom of the UIScrollView when the keyboard is shown</em></p>
  
  <p>Thank You!!</p>
  
  <p>Below is my current code</p>
  
  <pre><code>func textFieldDidBeginEditing(textField: UITextField) {
      var bottomOffset: CGPoint = CGPoint(x: 0, y: mainScrollView.contentSize.height - mainScrollView.bounds.size.height);
      mainScrollView.setContentOffset(bottomOffset, animated: true);
  }
  
  func keyboardDidShow(notification: NSNotification) {
      var userInfoDictionary: NSDictionary = notification.userInfo!;
  
      var keyboardSize: CGSize = userInfoDictionary.objectForKey(UIKeyboardFrameBeginUserInfoKey)!.CGRectValue().size;
  
      var contentInsets = UIEdgeInsets(top: 0, left: 0, bottom: keyboardSize.height, right: 0);
  
      mainScrollView.contentInset = contentInsets;
      mainScrollView.scrollIndicatorInsets = contentInsets;
  }
  
  func keyboardWillHide(notification: NSNotification) {
      var contentInsets = UIEdgeInsetsZero;
  
      mainScrollView.contentInset = contentInsets;
      mainScrollView.scrollIndicatorInsets = contentInsets;
  }
  </code></pre>