title: keyboardWillShow how to apply to only 1 textView in Swift iOS
body: <p>We have an app which looks like this:</p>
  
  <p><a href="http://i.stack.imgur.com/l3Z5I.png" rel="nofollow">App here</a></p>
  
  <p>We have <code>UITextViews</code> in the top and in the bottom of the view and I had been asking for some help in order to move the screen up when the <code>keyboard</code> appears.</p>
  
  <p>It actually works perfect but I'm wondering how to apply this only for the <code>UITextView</code> (<code>textViewInteriorDos</code>) in the bottom of the screen, which was touching the keyboard before. 
  How to apply correctly the <code>if/ else</code> statement in this methods guys??</p>
  
  <p>The top <code>UITextView</code> is not covered with the keyboard, so we don't need it.</p>
  
  <pre><code>class viewControllerCuatro: UIViewController, UITextViewDelegate {
  
  @IBOutlet weak var textViewInteriorUno: UITextView!
  @IBOutlet weak var textViewInteriorDos: UITextView!
  
  override func viewDidLoad() {
  
  
      self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "Atrás", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)
  
  
      **NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillShow:"), name:UIKeyboardWillShowNotification, object: self.view.window)
      NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide:"), name:UIKeyboardWillHideNotification, object: self.view.window)**
  
  
  
  
  }
  
  
      func keyboardWillShow(sender: NSNotification) 
  {
          // 1
          let userInfo: [NSObject : AnyObject] = sender.userInfo!
          // 2
          let keyboardSize: CGSize = userInfo[UIKeyboardFrameBeginUserInfoKey]!.CGRectValue.size
          let offset: CGSize = userInfo[UIKeyboardFrameEndUserInfoKey]!.CGRectValue.size
          // 3
          if keyboardSize.height == offset.height {
              UIView.animateWithDuration(0.1, animations: { () -&gt; Void in
                  self.view.frame.origin.y -= keyboardSize.height
              })
          } else {
              UIView.animateWithDuration(0.1, animations: { () -&gt; Void in
                  self.view.frame.origin.y += keyboardSize.height - offset.height
              })
              }
  
  
      }
  func keyboardWillHide(sender: NSNotification) {
              let userInfo: [NSObject : AnyObject] = sender.userInfo!
              let keyboardSize: CGSize = userInfo[UIKeyboardFrameBeginUserInfoKey]!.CGRectValue.size
              self.view.frame.origin.y += keyboardSize.height
          }
  override func viewWillDisappear(animated: Bool) {
          NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillShowNotification, object: self.view.window)
          NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillHideNotification, object: self.view.window)
      }
  
   override func touchesBegan(touches: Set&lt;UITouch&gt;, withEvent event: UIEvent?) {
  
      if textViewInteriorUno.text == ""  || textViewInteriorUno.text.isEmpty == true || textViewInteriorDos.text == "" || textViewInteriorDos.text.isEmpty == true {
  
  
          textViewInteriorUno.resignFirstResponder()
  
  
          textViewInteriorDos.resignFirstResponder()
      }
      else{
  
          self.textViewInteriorUno.resignFirstResponder()
  
          self.textViewInteriorDos.resignFirstResponder()
      }
  }
  
  func textView(textView: UITextView, shouldChangeTextInRange range: NSRange, replacementText text: String) -&gt; Bool{
  
      var shouldReplace = true // For most cases, return true, only modify if we have a special case
  
      // If the textView is 'textViewInteriorUno'
      if textView.isEqual(textViewInteriorUno) {
  
      let newLength = textViewInteriorUno.text.utf16.count + text.utf16.count - range.length
      shouldReplace = newLength &lt;= 12           // will be true if the length is &lt;= 12
  
      }
  
      else if textView.isEqual(textViewInteriorDos) {
  
      let newLength = textViewInteriorDos.text.utf16.count + text.utf16.count - range.length
      shouldReplace = newLength &lt; 13 // Will be true if the length &gt; 6
  
  
      }
  
      return shouldReplace
  }
  </code></pre>