user2183064
user2183064

Reputation: 91

KeyboardShrinksView makes lose focus

I have a problem with the KeyboardShrinksView feature that is included in Phonegap 2.6 (ios).

When I tap in the textarea where I want to include text, the keyboard appears and the webview is contracted as I wanted.

The problem is that I lose the focus on the textarea and the user has to tap again in the text area to start writing in it.

Is anyone having the same problem with this new feature?

Thanks!!

Upvotes: 9

Views: 2516

Answers (3)

Joe's Ideas
Joe's Ideas

Reputation: 540

I ran into this problem for iOS after upgrading from Phonegap 2.9 to 3.1. Solved by adding height=device-height to my meta tag, so it now looks like this:

<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable=no">

Upvotes: 0

ia3andy
ia3andy

Reputation: 523

add a tap (or touchstart) event on your input which will focus on your field.

element.on("tap", function(e){element.focus()});

The issue comes from the fact that focus is done on ios using the ghost click event. But the view has already changed (because of the keyboard) when it's fired.

This problem will be even more common on ios7 since KeyboardShrinksView is the default behavior...

Upvotes: 4

Poorva
Poorva

Reputation: 130

After the web view is contracted try writing this code.

  [TextFieldOnWhichFocusIsExpected BecomeFirstResponder];

Upvotes: 1

Related Questions