I know that this question has been asked over and over again, but nothing seems to be working for me. Most of the solutions around are pretty out of date, and the rest are incredibly huge blocks of code that are ten times larger then the actual projects coding. I have a few UITextFields lined up vertically, but when the keyboard launches to edit one, it covers up the text field. I was wondering if there is a simple beginner way to scroll the view up, and then back down when the editing starts and ends?
Thank you.
I have made solutions that work with scroll and non-scroll views using keyboard notification and a detection of the current first responder, but sometimes I use this trivial solution instead: The simple way is to detect the opening keyboard via the text field delegate's
textViewDidBeginEditing:
method and to move the entire view up. The easiest way to do this is with something along the lines of changingself.view.bounds.origin.y
to -100 (or whatever). Use the correspondingtextViewShouldEndEditing:
method to set it to the opposite, which is 100 in this case. Changingbounds
is a relative procedure. After changing it the frame is moved but the bounds origin is still zero.