Uncover content hidden by keyboard on iPad
I have a view with multiple UITextView
s which need to be tappable to the user to begin editing. However, in the landscape view of this UIView
, the keyboard covers up more than half of these fields. What's the reccomended way to make sure that the use开发者_运维问答r can still access the content under the keyboard while maintaining simplicity?
You can use the textField Delegate methods to solve your problem.
For example when the user taps the textField to begin editing, a delegate method will be called - (void)textFieldDidBeginEditing:(UITextField *)textField
in this method change your main view's frame and push it a bit up. For example in iPad in Portrait orientation the frame of your main view would be (0,0,768,1024) now in that delegate method change the frame to (0,-50, 768,1024). And when the user is done editing and performs some other action again reset the frame of the view to its original (0,0,768,1024) using other delegate methods like - (void)textFieldDidEndEditing:(UITextField *)textField
.
The more ideal thing would be to put all your objects in one subview and change the frame of that subview rather than changing the frame of the main view.
I hope this helps.
精彩评论