Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KeyboardShrinksView makes lose focus

Tags:

ios

cordova

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!!

like image 765
user2183064 Avatar asked Apr 22 '13 14:04

user2183064


2 Answers

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...

like image 137
ia3andy Avatar answered Nov 11 '22 16:11

ia3andy


After the web view is contracted try writing this code.

  [TextFieldOnWhichFocusIsExpected BecomeFirstResponder];
like image 21
Poorva Avatar answered Nov 11 '22 16:11

Poorva