3

Update - Solution

@jfurr's answer in this post solve the problem.

Change this

<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0" />

into

<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, target-densityDpi=device-dpi" />

Update - Workaround

But if I reduce the height of the web view for at least 37 points for 4 inches iOS 7 device (36 or less doesn't work), the focus would remain in the upper text field.

CGRect aCGRect = [webView frame];
aCGRect.size.height = [[UIScreen mainScreen] applicationFrame].size.height - 37;    
[webView setFrame:aCGRect];

Don't know why it's like this.

Problem

There is a full screen web view, on which two text fields (not iOS native text field) aligned vertically in the middle of the web view. When I click on the upper text field, it is expected to see the keyboard shown up and the focus lands on the upper text field with the web view appropriately move up a little bit.

Now the unexpected result is that when the upper text field is touched, the keyboard is able to show up, but the focus lands on the lower text field, and the cursor also move to the lower text field. However, this unexpected result happens only in iOS 7. It works as expected in iOS 6 and 5.

Community
  • 1
  • 1
George
  • 3,384
  • 5
  • 40
  • 64
  • 1
    I feel your pain, many of the text input fields within our webviews are causing all sorts of issues with scrolling/resizing webviews even to the point where the focused field is no longer visible. Most of the issues happen when the keyboard and the text input are relatively close to each other on the page, but not always in scenarios where anything would be obstructed. This is very frustrating, and we should probably relay issues to Apple and hope for fixes from them. – TahoeWolverine Jan 22 '14 at 21:23
  • @TahoeWolverine thanks for sharing your thought on it :D – George Jan 23 '14 at 03:31

1 Answers1

1

(Same as listed as Update - Solution in the post.)

@jfurr's answer in this post solves the problem:

ios7 issues with webview focus when using keyboard html

Change this

<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0" />

into

<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, target-densityDpi=device-dpi" />
pkamb
  • 33,281
  • 23
  • 160
  • 191
George
  • 3,384
  • 5
  • 40
  • 64