0
votes

Easy one of the day, impress your friends!

Hybridwebview from xlabs - https://github.com/XLabs/Xamarin-Forms-Labs/wiki/HybridWebView

Attempting to load content as shown below.

Works fine on android, nothing shows up on ios using either str or str2.

Any ideas?

CSHARP

    void OnButtonStaticLoadClicked(object sender, EventArgs args)
    {
        // doesnt load on ios
        string str = @"<html><body><h2>hello there</h2><div>four score and seven years ago </div></body></html>";
        string str2 = @"<!DOCTYPE html>" +
            @"<html>" +
            @"<body bgcolor='yellow'><h2>hello there</h2><div style='font-color:black'>four score and seven years ago</div>" +
            @"</body></html>";

        HybridWebView_Main.LoadContent(str2);
    }

XAML

<StackLayout>
  <Button x:Name="Button_LoadStatic" Text="Load Static HTML" Clicked="OnButtonStaticLoadClicked" />
  <controls:HybridWebView x:Name="HybridWebView_Main"
                      HorizontalOptions="FillAndExpand"
                      VerticalOptions="FillAndExpand"
                      BackgroundColor="Yellow"
                      HeightRequest="300" />
</StackLayout>
1

1 Answers

2
votes

For some reason the renderer is not registered. Add

[assembly: ExportRenderer(typeof(HybridWebView), typeof(HybridWebViewRenderer))]

in your iOS code and it will work.