Bug 40656 - iOS WebView Rotation, Sizing and Scaling issues
Summary: iOS WebView Rotation, Sizing and Scaling issues
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.2.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-04-24 01:04 UTC by Adam
Modified: 2016-04-24 14:09 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Adam 2016-04-24 01:04:15 UTC
This is a regression that started happening in 2.2.0, in 2.1.0 this all works as expected

1 - Rotate the webview once and of course due to the never getting out of IN_PROGRESS bug report: https://bugzilla.xamarin.com/show_bug.cgi?id=30047 it doesn't give the correct height. But by doing this you could essentially fix it if you had it full screen (which I did)

   public override void LayoutSubviews()
    {
        base.LayoutSubviews();

        CGRect bounds = UIScreen.MainScreen.Bounds;
        bounds.Height = NativeView.Bounds.Height;

        NativeView.Bounds = bounds;

    }
This now no longer works.

2 - Do a rotate to landscape, then back to portrait and the width of the WebView is half the screen.

3 - Go away from the WebView, then go back to the page, then rotate and you get this exception (everytime)

System.ObjectDisposedException: Cannot access a disposed object.

Object name: 'WebViewRenderer'.
Of course if I do this it stops the error

  protected override void Dispose(bool disposing)
        {
           // base.Dispose(disposing);
        }

But it looks like the WebViewRenderer shouldn't be disposed at that point until the actual page or control is disposed of.

This was all done on an iPhone 4S and 6 simulators on iOS 9.2
Comment 1 Adam 2016-04-24 01:20:16 UTC
Forgot to add that the first time you view a webpage in the WebView the content inside it also hasn't scaled properly and is larger than usual. A move to another page (ContentPage) and then back to the ContentPage with a WebView, it will then scale the content to the correct height.
Comment 2 Rui Marinho 2016-04-24 14:09:34 UTC
Should be fixed in 2.2.0-pre5