2016-10-06 41 views
3

私はUICollectionViewを持っています。そして、didDeselectItemAtがトリガーされない項目を選択したときに、他の項目を選択すると、最初にトリガーされます。どうして?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) 

} 

妨害する可能性collectionView上記の一切のビューがありません:

これは、メソッドが実装されています。

+3

didSelect vs ** De ** select? – Larme

+1

[didSelectRowAtIndexPathが間違ったIndexPathを返す可能性があります](http://stackoverflow.com/questions/4118993/didselectrowatindexpath-returns-wrong-indexpath)この質問は「UICollectionView」ではなく「UICollectionView」ですが、システム/理由は同じ。 – Larme

答えて

7

didDeselectItemAtではありません - 二回目に呼ばれて、あなたが任意の項目を選択した場合、それが

didSelectItemAtある

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

を呼び出すことの後 - に呼ばれています初めて商品を選択した場合、

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

うわー、ありがとう:-) –

関連する問題