簡體   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