UICollectionView reloads cell after `endInteractiveMovement`

Number:rdar://34933061 Date Originated:10/11/2017
Status:Open Resolved:
Product:iOS Product Version:iOS 11
Classification: Reproducible:Always
Behavior for iOS 11 UICollectionView has changed after `endInteractiveMovement()` or `cancelInteractiveMovement()` is called such that it now reloads the cell at the new index path after it is moved/cancelled asynchronously (seemingly triggered from a call to layout subviews in the collection view). Whereas, in iOS 10, the cell did not reload and simply maintained the view it had.

This will at least cause the cell to flash as the layout is invalidated and reloaded.

But the real issue arises when you want to manipulate cells directly after `endInteractiveMovement()` and change the source data such that a different number of cells exist in the collection than did before the reorder took place. Because the `cellForItemAt indexPath` call is delayed by the animation, it will try loading the cell after it may have been removed (via `deleteItems(at:)`) Then you get a crash.

Steps to Reproduce:
1. Create a UICollectionView.
2. Implement the interactive movement methods with a LongPressGestureRecognizer.
3. Run the app.
4. Press and hold to drag. When the drag completes the moved cell will flash and reload.

Expected Results:
The cell should move to it's new location seamlessly in it's new state with no view flashing.

Actual Results:
The view flashes as the cell is removed and laid out again.

iOS 11 (15A372)


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!