UICollectionView didDeselectItemAt未被触发

Ján*_*nos 4 ios uicollectionview swift swift3

我有一个UICollectionView,当选择一个项目didDeselectItemAt没有被触发时,但是当选择其他项目时,第一个项目将被触发.为什么?

这是有方法实现:

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

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

}
Run Code Online (Sandbox Code Playgroud)

上面没有collectionView可能干扰的视图.

Anb*_*hik 8

不是

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

override func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
Run Code Online (Sandbox Code Playgroud)

它是

didSelectItemAt - 在第一次调用时,如果您选择它将调用的任何项目

 override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 
Run Code Online (Sandbox Code Playgroud)