0
我有一個包含三個數據源的集合視圖以及可以選擇或取消選擇的項目。無法在Collectionview.reloaddata()後選擇UICollectionViewcell()
switch atIndex {
case 0:
print("Fashion Category")
datasource = categories as! [Category]
categoryIndex = 0
//update states for data from Firebase depending on category
checkCategorieStates(category: "fashion")
categories = Categories().categories
headerView.categoryButton.setTitle("Fashion", for: .normal)
case 1:
print("Food Category")
datasource = foodCategories as! [Category]
categoryIndex = 1
//update states for data from Firebase depending on category
checkCategorieStates(category: "food")
categories = foodCategories
headerView.categoryButton.setTitle("Food", for: .normal)
case 2:
print("Bar Cateogry")
datasource = barCategories as! [Category]
categoryIndex = 2
//update states for data from Firebase depending on category
checkCategorieStates(category: "drinks")
categories = barCategories
headerView.categoryButton.setTitle("Drinks", for: .normal)
default:
print("Some other category")
}
予先選擇一個類別,然後加載用於一個的CollectionView數據源和reloadData()
。 然後我選擇幾個項目或取消選擇它們。
collectionview.reloadData()
collectionview.isScrollEnabled = true
然後我回去。創建一個空的數據源並且reloadData()
因此它不顯示任何項目。
然後,我選擇另一個類別並加載另一個數據源,然後爲collectionview加載reloadData()
以顯示這些項目。
但現在我無法再選擇新的項目。
我認爲問題在於重用UICollectionviewcells內,隨着更多的細胞我選擇的第一次,更細胞,我不能選擇reloadData()
以上所有集合視圖都是一樣的嗎? – Lumialxk
是的,我基本上只是清空同一個Collectionview的數據源'reloaddata()'並在集合視圖之上顯示一個按鈕來選擇另一個數據源並使用新的數據源重新加載相同的Collectionview。 – Mike