title: Animating frame occasionally works
body: <p>Here's my function that animates my view</p>
  
  <pre><code>func animateViewMoving (up:Bool, moveValue :CGFloat) {
  
      let movementDuration:NSTimeInterval = 0.3
      let movement:CGFloat = ( up ? -moveValue : moveValue)
      self.view.setNeedsLayout()
      UIView.animateWithDuration(movementDuration, animations: {
      self.view.layoutIfNeeded()
      self.view.frame.origin.y += movement
      })
  
  }
  </code></pre>
  
  <p>I call this function on these two functions of <code>UITextFieldDelegate</code> </p>
  
  <pre><code>func textFieldDidBeginEditing(textField: UITextField) {
  
          animateViewMoving(true, moveValue: 200)
  
  }
  
  func textFieldDidEndEditing(textField: UITextField) {
  
          animateViewMoving(false, moveValue: 200)
  
  }
  </code></pre>
  
  <p>The problem is this- Whenever I run my build and open the view for the first time, the view shifts up on pressing the textField and shifts down when editing the textField ends. However if I go back to a previous view and enter the view again, the view does not shift up on pressing the textField. Why is <code>animateWithDuration</code>  working irregularly? </p>