Hello,
I'm trying to implement a custom view renderer for my WebView and I can't figure out how to get a large webpage to automatically scale to fit the viewport.
using System;
using Xamarin.Forms.Platform.iOS;
using UIKit;
using Xamarin.Forms;
using ButtonCode;
using ButtonCode.iOS;
using Foundation;
[assembly: ExportRenderer(typeof(CustomWebView), typeof(CustomWebViewRenderer))]
namespace ButtonCode.iOS
{
public partial class CustomWebViewRenderer : WebViewRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.OldElement==null)
{
this.ScalesPageToFit = true;
//this.ScrollView.ScrollEnabled = false;
}
}
}
}
The code executes without error or warning. To be sure that the web view object is being accessed I tried another property, this.ScrollView.ScrollEnabled, and setting it to false had the expected effect.