xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.88k forks source link

[iOS] ListView cell layout broken after inserting new cells #4278

Open melimion opened 5 years ago

melimion commented 5 years ago

Description

After inserting new cells to beginning of source list, cells are displayed incorrectly. Some cells have white background (first screenshot) instead of content, some cells merged in one with gray background (second screenshot) without space between them.

Additionally, tap on this incorrect cells causes NRE with following stacktrace:

  at Xamarin.Forms.Platform.iOS.ContextActionsCell.get_ScrollDelegate () [0x00000] in <22793afa32544bc9bd4626e57194b3f0>:0 
  at Xamarin.Forms.Platform.iOS.ContextActionsCell.PrepareForDeselect () [0x00000] in <22793afa32544bc9bd4626e57194b3f0>:0 
  at Xamarin.Forms.Platform.iOS.ListViewRenderer+ListViewDataSource.OnItemSelected (System.Object sender, Xamarin.Forms.SelectedItemChangedEventArgs eventArg) [0x00068] in <22793afa32544bc9bd4626e57194b3f0>:0 
  at (wrapper delegate-invoke) System.EventHandler`1[Xamarin.Forms.SelectedItemChangedEventArgs].invoke_void_object_TEventArgs(object,Xamarin.Forms.SelectedItemChangedEventArgs)
  at Xamarin.Forms.ListView.OnSelectedItemChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\ListView.cs:580 
  at Xamarin.Forms.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) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:625 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00181] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:425 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:362 
  at Xamarin.Forms.ListView.NotifyRowTapped (System.Int32 groupIndex, System.Int32 inGroupIndex, Xamarin.Forms.Cell cell) [0x0004c] in D:\a\1\s\Xamarin.Forms.Core\ListView.cs:420 
  at Xamarin.Forms.Platform.iOS.ListViewRenderer+ListViewDataSource.RowSelected (UIKit.UITableView tableView, Foundation.NSIndexPath indexPath) [0x0006f] in <22793afa32544bc9bd4626e57194b3f0>:0 
  at Xamarin.Forms.Platform.iOS.ContextActionsCell+SelectGestureRecognizer.Tapped (UIKit.UIGestureRecognizer recognizer) [0x00044] in <22793afa32544bc9bd4626e57194b3f0>:0 
  at UIKit.UITapGestureRecognizer+Callback.Activated (UIKit.UITapGestureRecognizer sender) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIGestureRecognizer.cs:205 
--- End of stack trace from previous location where exception was thrown ---
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.cs:63 
  at Xf.Sandbox.iOS.Application.Main (System.String[] args) [0x00001] in /Users/gamer/Projects/Xf.Sandbox/Xf.Sandbox.iOS/Main.cs:17 

Steps to Reproduce

  1. Run sample
  2. Tap "attach" toolbar item
  3. Scroll list to top
  4. After scroll reaches top 10 elements, new items are inserted to list. Some cells are displayed incorrectly
  5. Tap on one of incorrectly displayed cells to cause NRE

Expected Behavior

Correctly displayed text and no exception on tap

Actual Behavior

Some cells displayed only partly, tap on them causes NRE

Basic Information

Screenshots

simulator screen shot - iphone x - 2018-11-01 at 12 24 00 simulator screen shot - iphone x - 2018-11-01 at 12 36 40

Reproduction Link

Xf.Sandbox.zip

pauldipietro commented 5 years ago

The issue appears to occur as described; thanks for the repro.

melimion commented 5 years ago

@pauldipietro @PureWeen

Any plans on fixing this?