You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Mike Kwan (JIRA)" <ji...@apache.org> on 2013/11/13 13:25:21 UTC

[jira] [Updated] (CB-5373) CDVViewController does not support shifted UIWebView

     [ https://issues.apache.org/jira/browse/CB-5373?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mike Kwan updated CB-5373:
--------------------------

    Description: 
*CDVViewController* does not play well with the *HideKeyboardFormAccessoryBar* set to *true* when the *UIWebView* has its origin shifted.

To reproduce this:

 - Create skeleton project via CLI
 - Configure *content src* to *http://www.google.co.uk/*
 - Configure *HideKeyboardFormAccessoryBar* to *true*
 - In the MainViewController add the following method:
{code}- (void)viewDidLoad
{
    [super viewDidLoad];
    
    CGRect frame = [[self view] bounds];
    frame.origin.y += 20;
    frame.size.height -= 20;
    
    [self.webView setFrame:frame];
}{code}
 - Load page, trigger keyboard by giving focus to the input field and dismiss the keyboard by tapping back on the page

The reason the bug occurs is because of the following line in *CDVViewController* in *hideKeyboardFormAccessoryBarEnd:*:

{code}self.webView.scrollView.frame = self.webView.frame;{code}

This will work as expected only if the *scrollView* origin matches the *UIWebView* origin which happens only at (0, 0). The correct code should be:

{code}self.webView.scrollView.frame = CGRectMake(0, 0, self.webView.frame.size.width, self.webView.frame.size.height);{code}

An example of the *scrollView* frame being set incorrectly:
!https://hostr.co/file/mt2TZrCaf51a/Screen-Shot-2013-11-13-at-12.22.08.png!

Example project demonstrating bug:
https://hostr.co/SVeUlWyvGPyp

  was:
*CDVViewController* does not play well with the *HideKeyboardFormAccessoryBar* set to *true* when the *UIWebView* has its origin shifted.

To reproduce this:

 - Create skeleton project via CLI
 - Configure *content src* to *http://www.google.co.uk/*
 - Configure *HideKeyboardFormAccessoryBar* to *true*
 - In the MainViewController add the following method:
{code}- (void)viewDidLoad
{
    [super viewDidLoad];
    
    CGRect frame = [[self view] bounds];
    frame.origin.y += 20;
    frame.size.height -= 20;
    
    [self.webView setFrame:frame];
}{code}

The reason the bug occurs is because of the following line in *CDVViewController*:

{code}self.webView.scrollView.frame = self.webView.frame;{code}

This will work as expected only if the *scrollView* origin matches the *UIWebView* origin which happens only at (0, 0). The correct code should be:

{code}self.webView.scrollView.frame = CGRectMake(0, 0, self.webView.frame.size.width, self.webView.frame.size.height);{code}

        Summary: CDVViewController does not support shifted UIWebView  (was: CDVViewController does not support UIWebView not at (0, 0))

> CDVViewController does not support shifted UIWebView
> ----------------------------------------------------
>
>                 Key: CB-5373
>                 URL: https://issues.apache.org/jira/browse/CB-5373
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 3.1.0
>            Reporter: Mike Kwan
>
> *CDVViewController* does not play well with the *HideKeyboardFormAccessoryBar* set to *true* when the *UIWebView* has its origin shifted.
> To reproduce this:
>  - Create skeleton project via CLI
>  - Configure *content src* to *http://www.google.co.uk/*
>  - Configure *HideKeyboardFormAccessoryBar* to *true*
>  - In the MainViewController add the following method:
> {code}- (void)viewDidLoad
> {
>     [super viewDidLoad];
>     
>     CGRect frame = [[self view] bounds];
>     frame.origin.y += 20;
>     frame.size.height -= 20;
>     
>     [self.webView setFrame:frame];
> }{code}
>  - Load page, trigger keyboard by giving focus to the input field and dismiss the keyboard by tapping back on the page
> The reason the bug occurs is because of the following line in *CDVViewController* in *hideKeyboardFormAccessoryBarEnd:*:
> {code}self.webView.scrollView.frame = self.webView.frame;{code}
> This will work as expected only if the *scrollView* origin matches the *UIWebView* origin which happens only at (0, 0). The correct code should be:
> {code}self.webView.scrollView.frame = CGRectMake(0, 0, self.webView.frame.size.width, self.webView.frame.size.height);{code}
> An example of the *scrollView* frame being set incorrectly:
> !https://hostr.co/file/mt2TZrCaf51a/Screen-Shot-2013-11-13-at-12.22.08.png!
> Example project demonstrating bug:
> https://hostr.co/SVeUlWyvGPyp



--
This message was sent by Atlassian JIRA
(v6.1#6144)