简体   繁体   中英

Swift - beginInteractiveMovementForItem on iOS 16

on iOS 16 beginInteractiveMovementForItem in collectionvView throws an error:

attempt to insert nil object from objects[0]' terminating with uncaught exception of type NSException

This is my code:

collectionView.beginInteractiveMovementForItem(at: selectedIndexPath)

Is there any alternative on iOS 16 to use? There is another question similar here: UICollectionView crash when moving items on iOS 16 beta but still no answer for this issue.

Simply by adding a delay it works now on iOS 16 as well.

DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
      collectionView.beginInteractiveMovementForItem(at: selectedIndexPath)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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