2015-09-08 3 views
0

Есть ли способ найти индекс раздела UICollectionView?Есть ли способ найти индекс раздела UICollectionView?

My CollectionView заполнен массивами, которые содержатся в основном массиве, и мне нужно выбрать соответствующий раздел.

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 

    let collectionCell: ChecklistCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("collectionCell", forIndexPath: indexPath) as! ChecklistCollectionViewCell 

    let section = //I need the index of the current section here! 

    let sectionArray = allCards[section] 

    collectionCell.imageCell.image = UIImage(named: sectionArray[indexPath.row]) 

    return collectionCell 

} 

Подобно тому, как это сделано здесь:

func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 

    let sectionArray = allCards[section] 
    return sectionArray.count 

} 
+0

ли вы понять это ?? –

ответ

1
let section = allCards[indexPath.section] 
+0

Ты, сэр, настоящий брат. – bkwebhero

Смежные вопросы