Search code examples
iphoneiosios4uiviewuitextfield

How to display a text field hidden by virtual keyboard?


I've layed out a view with some labels, a button and especially a text field in the bottom of this view. The issue is when the text field gets the focus, the iphone virtual keyboard hides the text field, so we can't see what we're typing (and I can't move the text field to another part without breaking this layout)...Any idea on how to fix this issue ?

Thx for helping,

Stephane


Solution

  • There is a method of textFieldDelegate calld

    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
    

    When this method gets called you can change frame property of you UIView and shift it upward.

    Same way when textFieldShouldEndEditing gets called you can shift view down again.

    Moreover, listing to notification UIKeyboardWillShowNotification and UIKeyboardWillHideNotification can also be useful to trigger view shifing.

    If you do not know how to slide view see this.

    http://iosdevelopertips.com/user-interface/sliding-views-on-and-off-screen-reader-contributions.html