title: My Scrollview doesn't scroll all the way up after pushing up the keyboard Swift iOS
body: <p>I have a scrollview with lots of textfields inside it. When I push up my scroll view so that the keyboard does not hide some of the subviews, I can't scroll all the way up to the top of scrollview. Here is my code. Can anyone help? </p>
  
  <p><img src="https://i.stack.imgur.com/nOPw1.png" alt="constraints of uiscrollview"></p>
  
  <pre><code>class IncomingPackageViewController: UIViewController{
      override func viewDidLoad() {
          super.viewDidLoad()
          NotificationCenter.default.addObserver(self,selector:#selector(self.keyboardWillShow),name:UIResponder.keyboardDidShowNotification, object: nil)
          NotificationCenter.default.addObserver(self,selector: #selector(self.keyboardWillHide),name:UIResponder.keyboardDidHideNotification, object: nil)
  
      }
  
      @objc func keyboardWillShow(notification: Notification) {
          guard let userInfo = notification.userInfo,
              let frame = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue else {return}
          let contentInset = UIEdgeInsets(top: 0, left: 0, bottom: frame.height, right: 0)
          if self.view.frame.origin.y == 0 {
              self.view.frame.origin.y -= contentInset.bottom
          }
      }
  
      @objc func keyboardWillHide(notification: Notification) {
          if self.view.frame.origin.y != 0 {
              self.view.frame.origin.y = 0
          }
      }
  }
  </code></pre>