草庐IT

ios - UICollectionView didDeselectItemAt 没有被触发

coder 2023-09-08 原文

I have a UICollectionView, and when selecting an item didDeselectItemAt not get triggered, but when selecting an other item, the first will get triggered.为什么?

这是有方法实现的:

override func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {

    let userSetting = userSettings[(indexPath as NSIndexPath).row]
    selectedUserSettingRecordName = userSetting.id
    containerViewController!.performSegue(withIdentifier: "message", sender:self)

}

collectionView 上方没有可能干扰的 View 。

最佳答案

不是

didDeselectItemAt - 第二次调用,如果您选择之后的任何项目,它将调用

override func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {

didSelectItemAt - 第一次被调用,如果您选择它会调用的任何项目

 override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 

关于ios - UICollectionView didDeselectItemAt 没有被触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39892884/

有关ios - UICollectionView didDeselectItemAt 没有被触发的更多相关文章

随机推荐