Xamarin Forms:Html 标签在 ios 中显示空白内容
Xamarin Forms: Html label is showing blank content in ios
我正在使用 Xam.Plugin.HtmlLabel
来显示我的项目数据。它在 android 和 windows 上运行良好。但是 ios 设备中没有显示任何内容。
我的代码:
<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";
我上传了一个样本here以供参考。
在你的情况下,你似乎忘记了在特定平台上初始化渲染器。
在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);
}
我使用标签 <u>
添加了标签的下划线。
您可以查看 https://github.com/luczha/HtmlLabel_demo 中的演示。
我正在使用 Xam.Plugin.HtmlLabel
来显示我的项目数据。它在 android 和 windows 上运行良好。但是 ios 设备中没有显示任何内容。
我的代码:
<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";
我上传了一个样本here以供参考。
在你的情况下,你似乎忘记了在特定平台上初始化渲染器。
在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);
}
我使用标签 <u>
添加了标签的下划线。
您可以查看 https://github.com/luczha/HtmlLabel_demo 中的演示。