繁体   English   中英

Xamarin.IOS表单LabelRenderer.UpdateText引发NullReferenceException

[英]Xamarin.IOS Forms LabelRenderer.UpdateText throws NullReferenceException

我正在使用Xamarin.Forms v2.4.0.38779,并且遇到了Null Pointer异常,该异常使应用程序崩溃。 我在2.4.0.18342中遇到了同样的问题

System.NullReferenceException: Object reference not set to an instance of an object

我猜想,当ListView的行数很少,并且我要添加新行,删除现有行并根据值更新行值时发生问题,我是从后台线程获取的。

由于数据输入过于频繁,因此在几秒钟内约有100次更新,因此它崩溃了。

仅供参考,我已将ObservationCollection绑定到ListView的ItemSource。 因此,我不管理自己的添加,删除和更新。

这是stackttrace:

LabelRenderer.UpdateText ()
LabelRenderer.OnElementPropertyChanged (System.Object sender,System.ComponentModel.PropertyChangedEventArgs e)
(wrapper delegate-invoke) :invoke_void_object_PropertyChangedEventArgs object,System.ComponentModel.PropertyChangedEventArgs)
BindableObject.OnPropertyChanged (System.String propertyName)
Element.OnPropertyChanged (System.String propertyName)
BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, 
Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent)
BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, 
Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes)
BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget)
BindingExpression.Apply (System.Boolean fromTarget)
BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 ()
NSAsyncActionDispatcher.Apply ()
(wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.String principalClassName,System.String delegateClassName)
Application.Main (System.String[] args)

有谁知道如何解决这个问题?

仅供参考,这与如何解决NullPointerException有关,因为Xamarin.Forms代码不是我所有的。 我将其用作第三方模块。

更改列表视图上的CachingStrategy似乎也是一种解决方法。 基于https://bugzilla.xamarin.com/show_bug.cgi?id=59813

对我来说,已修复了将CachingStrategy更改为RecycleElement的问题,但是据报告,从上面的链接可以更改为RetainElement可以解决。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM