title: Swift : scroll the view up when keyboard shows
body: <p>I have a scrollView that i want to scroll up when the keyboard is shown.</p>
  
  <p>I have a crash with this error when the keyboard show : </p>
  
  <p>2014-09-29 14:48:50.738 swrd[1563:472888] -[swrd.EditPhotoViewController keyboardWasShown]: unrecognized selector sent to instance 0x14ed36640</p>
  
  <p>Here is my code, what's wrong ?:</p>
  
  <pre><code>   func registerForKeyboardNotifications ()-&gt; Void   {
  
      NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWasShown", name: UIKeyboardDidShowNotification, object: nil)
  
      NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillBeHidden", name: UIKeyboardWillHideNotification, object: nil)
  
  
  }
  
  func deregisterFromKeyboardNotifications () -&gt; Void {
      let center:  NSNotificationCenter = NSNotificationCenter.defaultCenter()
      center.removeObserver(self, name: UIKeyboardDidHideNotification, object: nil)
      center.removeObserver(self, name: UIKeyboardWillHideNotification, object: nil)
  
  
  }
  
  
   func keyboardWasShown (notification: NSNotification) {
  
      let info : NSDictionary = notification.userInfo!
      let keyboardSize = info.objectForKey(UIKeyboardFrameBeginUserInfoKey)?.frame
  
      let insets: UIEdgeInsets = UIEdgeInsetsMake(self.scrollView.contentInset.top, 0, keyboardSize!.height, 0)
  
      self.scrollView.contentInset = insets
      self.scrollView.scrollIndicatorInsets = insets
  
      self.scrollView.contentOffset = CGPointMake(self.scrollView.contentOffset.x, self.scrollView.contentOffset.y + keyboardSize!.height)
  
  }
  
  func keyboardWillBeHidden (notification: NSNotification) {
  
      let info : NSDictionary = notification.userInfo!
      let keyboardSize = info.objectForKey(UIKeyboardFrameBeginUserInfoKey)?.frame
  
      let insets: UIEdgeInsets = UIEdgeInsetsMake(self.scrollView.contentInset.top, 0, keyboardSize!.height, 0)
  
      self.scrollView.contentInset = insets
      self.scrollView.scrollIndicatorInsets = insets
  
  
  
  }
  
  
   override func viewWillAppear(animated: Bool) {
      super.viewWillAppear(true)
  
  
  
     self.registerForKeyboardNotifications()
  
  }
  
   override func viewWillDisappear(animated: Bool) {
      super.viewWillDisappear(true)
  
      self.deregisterFromKeyboardNotifications()
  
  }
  </code></pre>