Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • The Screen moves up even if it is not at the bottom. ie, if the text field is on the top it moves out of the screen. How to control that case? Commented Nov 13, 2014 at 10:58
  • @MELWIN Just add after this line: int movement = (up ? -movementDistance : movementDistance); if (textField.frame.origin.y < self.view.frame.size.height - keyboard.height) { movementDistance = 0 } Please not that the keyboard variable is the CGRect of the keyboard that pops up which you get by doing: let keyboard = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey]!.CGRectValue())! Commented Aug 2, 2016 at 16:47