I don't know why my Xamarin.Forms custom renderer doesn't work if I put it into a library and only on iOS, somebody could help me?
[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();
}
It works fine on Android, UWP and iOS if into the project.
https://github.com/matteobortolazzo/HtmlLabelPlugin
Add a do-nothing Initialize
static method to your HtmlLabelRenderer
class to insure your renderer types are loaded before Forms
public static void Initialize()
{
}
In your AppDelegate
before Forms.Init()
, call your Initialize method:
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With