Xamarin表单Xfx。控制页面关闭时的异常

Xamarin表单Xfx。控制页面关闭时的异常,xamarin,xamarin.forms,xamarin.ios,custom-renderer,Xamarin,Xamarin.forms,Xamarin.ios,Custom Renderer,我在xamarin表单应用程序中使用Xfx.Controls进行浮动标签输入。 它在安卓上运行良好 但在iOS上运行时,在浮点输入上填充文本并关闭页面后将抛出异常 System.NullReferenceException:对象引用未设置为实例 一个物体在 Xfx.Controls.iOS.renders.xfxentryrendertouch.OnElementChanged 如何解决此问题?这是插件内部的问题,因此您可以熟悉插件代码并自行修复错误,然后在github上提交问题并等待最终修复。

我在xamarin表单应用程序中使用Xfx.Controls进行浮动标签输入。 它在安卓上运行良好

但在iOS上运行时,在浮点输入上填充文本并关闭页面后将抛出异常

System.NullReferenceException:对象引用未设置为实例 一个物体在 Xfx.Controls.iOS.renders.xfxentryrendertouch.OnElementChanged


如何解决此问题?

这是插件内部的问题,因此您可以熟悉插件代码并自行修复错误,然后在github上提交问题并等待最终修复。

这是插件内部的问题,因此您可以熟悉插件代码并自行修复错误所有人都必须在他们的github上提交问题,并等待问题最终得到解决。

根据

这是因为在xamarin 4中正确调用了Dispose 在渲染器上(不知道为什么在以前的版本中没有)。。。 控件在进入OneElementChanged时为null,因此取消订阅 失败。因此,OneElementChanged应该检查控件空在哪里 适用的

因此,临时解决方法是使用如下自定义渲染器:

public class CustomXfxEntryRendererTouch : XfxEntryRendererTouch
    {
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                SetElement(null); //trigger elementchange before base dispose happens https://github.com/XamFormsExtended/Xfx.Controls/issues/97
            }

            base.Dispose(disposing);
        }
    }
根据一篇文章中的评论

这是因为在xamarin 4中正确调用了Dispose 在渲染器上(不知道为什么在以前的版本中没有)。。。 控件在进入OneElementChanged时为null,因此取消订阅 失败。因此,OneElementChanged应该检查控件空在哪里 适用的

因此,临时解决方法是使用如下自定义渲染器:

public class CustomXfxEntryRendererTouch : XfxEntryRendererTouch
    {
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                SetElement(null); //trigger elementchange before base dispose happens https://github.com/XamFormsExtended/Xfx.Controls/issues/97
            }

            base.Dispose(disposing);
        }
    }

确保添加导出渲染器。我是xamarin和C#的新手,所以我想这会帮助那些还在学习的人。页面(XfxEntry)和自定义渲染器(CustomXFXentryRenderTouch)中使用的提要控件


确保添加导出渲染器。我是xamarin和C#的新手,所以我想这会帮助那些还在学习的人。页面(XfxEntry)和自定义渲染器(CustomXFXentryRenderTouch)中使用的提要控件


如果要使用不带插件的浮动标签,请更新xamarin并为xaml中的正常条目提供visual=“Material”。如果要使用不带插件的浮动标签,请更新xamarin并为xaml中的正常条目提供visual=“Material”。