Skip to content

Instantly share code, notes, and snippets.

@pisarukv
Last active August 29, 2015 14:12
Show Gist options
  • Save pisarukv/89c59caf15e7436f261e to your computer and use it in GitHub Desktop.
Save pisarukv/89c59caf15e7436f261e to your computer and use it in GitHub Desktop.
Xamarin Studio
Version 5.7 (build 660)
Xamarin.iOS
Version: 8.6.0.41 (Enterprise Edition)
#1 ViewRenderer Problem
//.... Dont work correctly. When happenning dispose ViewRendere can't find control and throw NullReferenceException
override void OnElementChanged(ElementChangedEventArgs<View> e)
{
base.OnElementChanged(e);
}
//....
//.... Partial solution, it's work, but if you have subviews with gestures this code won't work correctly
override void OnElementChanged(ElementChangedEventArgs<View> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
SetNativeControl(new UIView());
}
}
//....
//.... Probably right solution
override void OnElementChanged(ElementChangedEventArgs<View> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
var view = new UIView();
view.AddSubviews(Subviews);
SetNativeControl(view);
}
}
//....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment