Mat*_*zzo 5 forms custom-renderer ios xamarin
我不知道为什么我的 Xamarin.Forms 自定义渲染器在我将它放入库中并且仅在 iOS 上不起作用时,有人可以帮助我吗?
[assembly: ExportRenderer(typeof(HtmlLabel), typeof(HtmlLabelRenderer))]
namespace Plugin.HtmlLabel.iOS
{
public class HtmlLabelRenderer : LabelRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
{
base.OnElementChanged(e);
if (Control == null) return;
UpdateMaxLines();
UpdateText();
}
Run Code Online (Sandbox Code Playgroud)
如果进入项目,它在 Android、UWP 和 iOS 上运行良好。
向您的类添加一个不执行任何操作的Initialize静态方法,以确保您的渲染器类型在Forms之前HtmlLabelRenderer加载
public static void Initialize()
{
}
Run Code Online (Sandbox Code Playgroud)
在您的AppDelegate before Forms.Init()中,调用您的 Initialize 方法:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
Plugin.HtmlLabel.iOS.HtmlLabelRenderer.Initialize();
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
897 次 |
| 最近记录: |