我試圖取消選擇以前選擇的但在集合視圖中當前不可見的單元格。我使用此代碼:取消選擇當前不可見的單元格
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.1s就足夠了。
我與'UITableView'類似的問題選擇/取消選擇創建後細胞;該解決方案是調用'super.tableView:deselectRowAtIndexPath:'。 –
一些非常重要的事情發生在我的實現collectionView(_:didDeselectItemAtIndexPath :),它需要被稱爲 – brumbrum