Forum Xamarin.iOS

My ViewRenderer isn't on the screen

tematimtematim FRMember ✭✭
edited January 2017 in Xamarin.iOS

Hello,

I try to use this method : http://www.goxuni.com/672412-creating-a-xamarin-forms-custom-renderer-for-a-flexgrid-cell-template/

I copy/paste the code, and nothing is present on the screen.

My code :

[assembly: ExportRenderer(typeof(ExtendedEntry), typeof(ExtendedEntryRenderer))]
namespace vost.iOS.CustomRenderer
{
    public class ExtendedEntryRenderer : ViewRenderer<ExtendedEntry, UIView>
    {
        UIView layoutPanel;
        UILabel textValue;

        protected override void OnElementChanged(ElementChangedEventArgs<ExtendedEntry> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                // initialize layout
                layoutPanel = new UIView();
                // initialize label

                textValue = new UILabel()
                {
                    TextColor = UIColor.Black,
                    TextAlignment = UITextAlignment.Left,
                    Lines = 1
                };
                textValue.Layer.MasksToBounds = false;
                textValue.Text = e.NewElement.Placeholder;
                textValue.Frame = new CGRect(25, 0, 100, 25);
                layoutPanel.AddSubview(textValue);
                // set control
                SetNativeControl(layoutPanel);
            }

            if (e.OldElement != null)
            {
                // unsubscribe
            }

            if (e.NewElement != null)
            {
                // subscribe
                textValue.Text = e.NewElement.Placeholder;
            }
        }
    }
}

Is it possible to help me to view my label ?

Regards

Best Answer

Answers

Sign In or Register to comment.