Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

ListView with CachingStrategy="RecycleElement" UIKit Consistency error

$
0
0

Using Visual Studio 2019 Preview, I created an Xamarin Forms Shell project with iOS and Android apps.

I updated the MockDataStore to add 1000 items to the list.

The list view has CachingStrategy="RecycleElement"

        <ListView 
            x:Name="ItemsListView" 
            ItemsSource="{Binding Items}"
            VerticalOptions="FillAndExpand"
            HasUnevenRows="true"
            IsPullToRefreshEnabled="false"
            CachingStrategy="RecycleElement"
            ItemSelected="OnItemSelected">

When I run the app in the iOS simulator or on an iPhone, I can scroll the list, but eventually the app crashes with the error below.

If I change the CachingStrategy="RecycleElementAndDataTemplate", the error no longer occurs.

Any idea why? What is it doing under the covers that I need to account for?

Thank you,

Michael

Unhandled Exception:
UIKit.UIKitThreadAccessException: UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread.
at UIKit.UIApplication.EnsureUIThread () [0x0001a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/UIKit/UIApplication.cs:88
at UIKit.UIGestureRecognizer.RemoveTarget (Foundation.NSObject target, System.IntPtr action) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/UIKit/UIGestureRecognizer.g.cs:342
at UIKit.UIGestureRecognizer.OnDispose () [0x00016] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/UIKit/UIGestureRecognizer.cs:41
at UIKit.UIGestureRecognizer.Dispose (System.Boolean disposing) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/UIKit/UIGestureRecognizer.g.cs:959
at Foundation.NSObject.Finalize () [0x00000] in /Library/Fr
ameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/Foundation/NSObject2.cs:143
2019-02-04 11:41:49.073822-0500 WhiskyPassport.iOS[19858:1375488] Unhandled managed exception:
UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread. (UIKit.UIKitThreadAccessException)
at UIKit.UIApplication.EnsureUIThread () [0x0001a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/UIKit/UIApplication.cs:88
at UIKit.UIGestureRecognizer.RemoveTarget (Foundation.NSObject target, System.IntPtr action) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/UIKit/UIGestureRecognizer.g.cs:342
at UIKit.UIGestureRecognizer.OnDispose () [0x00016] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/UIKit/UIGestureRecognizer.cs:41
at UIKit.UIGestureRecognizer.Dispose (System.Boolean disposing) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin
.iOS/UIKit/UIGestureRecognizer.g.cs:959
at Foundation.NSObject.Finalize () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/Foundation/NSObject2.cs:143


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>