mkc842
mkc842

Reputation: 2381

manipulating the keyboard: change frame, edit text field other than the one tapped

I'm having trouble finding info on manipulating the keyboard. Here's what I want to do:

When the user touches a text field, I want a keyboard to appear. However:

1) I want to move the keyboard up 30 pixels so that another view is visible south of it.

2) The keyboard should not actually edit the text field the user touched. A multiline text view will be presented for the user to edit instead.

I'm not sure of the best strategy and I don't know the methods I'll need to use or properties I'll need to set. Some sample code would be greatly appreciated.

Upvotes: 0

Views: 169

Answers (1)

lnafziger
lnafziger

Reputation: 25740

As @HenryHarris says, you can't move the keyboard (or more appropriately shouldn't, as Apple expects it to be where they put it and will most likely reject your app if you start messing with it).

You can on the other hand, switch to a different view when they tap the text field by using something like this:

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    // Present your text view, let's call it myTextView for now, and then tell it to start accepting input:
    [myTextView becomeFirstResponder];

    // Now return NO so that the textField does NOT become the first responder:
    return NO;
}

Upvotes: 2

Related Questions