简体   繁体   中英

Xamarin Forms: Html label is showing blank content in ios

I am using Xam.Plugin.HtmlLabel for showing data on my project. It is working fine on android and windows. But nothing is showing in ios devices.

My code:

<htmllabel:HtmlLabel
    x:Name="message_label"
    VerticalOptions="Start"
    VerticalTextAlignment="Center"
    TextColor="Black">
    <htmllabel:HtmlLabel.FontSize>
        <OnIdiom x:TypeArguments="x:Double">
            <OnIdiom.Phone>20</OnIdiom.Phone>
            <OnIdiom.Tablet>30</OnIdiom.Tablet>
            <OnIdiom.Desktop>20</OnIdiom.Desktop>
        </OnIdiom>
    </htmllabel:HtmlLabel.FontSize>
</htmllabel:HtmlLabel>


message_label.Text = "htmldata";

I have uploaded a sample here for the reference.

In your case, you seems forget to init the renderer in specific platforms.

in iOS

using LabelHtml.Forms.Plugin.iOS;
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
   HtmlLabelRenderer.Initialize();
   global::Xamarin.Forms.Forms.Init();
   LoadApplication(new App());

   return base.FinishedLaunching(app, options);
}

I used the tag <u> to add under line of the label.

在此处输入图像描述

You could check the demo from https://github.com/luczha/HtmlLabel_demo .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM