Xamarin.iOS:每次打开应用程序时,自定义视图都会多次出现在彼此的顶部

Xamarin.iOS:每次打开应用程序时,自定义视图都会多次出现在彼此的顶部,xamarin,xamarin.ios,custom-controls,custom-view,Xamarin,Xamarin.ios,Custom Controls,Custom View,我有一个简单的自定义控件,它由单个元素UIPickerView组成 [Register("CustomPicker")] public class CustomPicker : UIView, IComponent { public CustomPicker(IntPtr p) : base(p) { } public ISite Site { get; set; } public event EventHandler Disposed; p

我有一个简单的自定义控件,它由单个元素UIPickerView组成

[Register("CustomPicker")]
public class CustomPicker : UIView, IComponent
{
    public CustomPicker(IntPtr p) : base(p)
    {
    }

    public ISite Site { get; set; }

    public event EventHandler Disposed;

    public override void Draw(CGRect rect)
    {
        base.Draw(rect);

        using (var g = UIGraphics.GetCurrentContext())
        {
            var label = new UIPickerView(new CGRect(rect.X, rect.Y, rect.Width, rect.Height));
            label.Model = new PeopleModel();
            AddSubview(label);
        }
    }
}
我有一个简单的故事板:

然后,每次我让应用程序进入后台(而不是终止)并再次打开它时,我都会在现有应用程序的基础上为picker设置一个应用程序,如下所示:


知道我做错了什么吗?当应用程序进入后台时,是否有一种特定的方法来“删除”视图?

这里有一个指向该项目的链接:很抱歉,我无法在您的项目中重现该问题。你的项目在我这方面做得很好,你能再检查一下吗?我仍然能看到这个问题。尝试几次重新打开应用程序,最终它将进入此状态运行项目,按home按钮(应用程序转到后台),然后重新打开它,对吗?是的,在重新打开之间尝试在选择器中滚动