I’d like to move up my view, when the keyboard is shown. The keyboard (height: 216) should push up my view with it’s height. Is this possible with a simple code?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To move the view
up, just change itscenter. First, keep the original one in aCGPointproperty.Then, change as needed when keyboard shows up:
Finally, restore it when keyboard is hidden:
Add animation sugar as you wish
You have more than one way to know when the keyboard appears.
Observing UIKeyboardDidShowNotification notification.
Do the opposite with
UIKeyboardDidHideNotification.-OR-
Implement UITextFieldDelegate
Detect when editing begin/end to move views around.
Depending on the actual text fields you may need to track in which field is the user editing, add a timer to avoid moving views too much.