简体   繁体   English

Swift - beginInteractiveMovementForItem on iOS 16

[英]Swift - beginInteractiveMovementForItem on iOS 16

on iOS 16 beginInteractiveMovementForItem in collectionvView throws an error: on iOS 16 beginInteractiveMovementForItem in collectionvView 抛出错误:

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? iOS 16 有没有其他选择可以使用? There is another question similar here: UICollectionView crash when moving items on iOS 16 beta but still no answer for this issue.这里还有一个类似的问题: UICollectionView 在 iOS 16 beta 上移动项目时崩溃,但仍然没有解决这个问题。

Simply by adding a delay it works now on iOS 16 as well.只需添加一个延迟,它现在也可以在 iOS 16 上运行。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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