0

以前に選択されていたが、現在コレクション ビューに表示されていないセルの選択を解除しようとしています。私はこのコードを使用しています:

        let optionalSelectedItems = collectionView.indexPathsForSelectedItems()
        if let selectedItems = optionalSelectedItems{
        for indexPath in selectedItems{

         self.collectionView.deselectItemAtIndexPath(indexPath, animated: true)
         self.collectionView.delegate?.collectionView!(self.collectionView, didDeselectItemAtIndexPath: indexPath)
        }

の実装では、かなり重要なことが行われていますfunc collectionView(_:didDeselectItemAtIndexPath:)。選択を解除すると、他のビューでイベントがトリガーされます。現在画面外にあり、メモリ内にないセルの選択を解除しているため、これはエラーをスローします。短期間だけセルをメモリに入れるにはどうすればよいですか? 選択を解除するだけでよいので、0.1 秒で十分だと思います。

4

1 に答える 1