title: UIScrollView scroll up on Keyboard
body: <p><strong>Problem Statement</strong> : I have Nib file of UIView contains UIScrollview, In scrollview I have several TextFields and a TextView at the Bottom. What I want is to scroll upward when textfield or Textview starts editing. </p>
  
  <p>What I tried : </p>
  
  <p>In custome Method </p>
  
  <pre><code>NotificationCenter.default.addObserver(self, selector: #selector(keyboardWasShown(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
  </code></pre>
  
  <p>I am calling this method parent view.</p>
  
  <p>Notification Handling: </p>
  
  <pre><code>func keyboardWasShown(notification: NSNotification)
  {
      var userInfo = notification.userInfo!
      var keyboardFrame:CGRect = (userInfo[UIKeyboardFrameBeginUserInfoKey] as! NSValue).cgRectValue
      keyboardFrame = self.convert(keyboardFrame, from: nil)
  
      var contentInset:UIEdgeInsets = self.mainScroll.contentInset
      contentInset.bottom = keyboardFrame.size.height
      self.mainScroll.contentInset = contentInset
  }
  </code></pre>
  
  <p>This is working perfectly for UITextFields, But not working UITextView. Any idea where is the mistake. </p>
  
  <p>PS: I have set the Delegates of UITextField and UITextView as well.</p>
  
  <p>Any help will be much appreciated. </p>