У меня есть следующий код, который помещает вид коллекции в одну или две колонны, в зависимости от размера экрана:UICollectionView reuseIdentifier в sizeForItemAtIndexPath - быстр
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
let size = collectionView.frame.width
if (size > 500) {
return CGSize(width: (size/2) - 8, height: (size/2) - 8)
}
return CGSize(width: size, height: size)
}
Я хотел бы изменить это, так высота зависит от повторного использования. Есть два я использую - установить что-то вроде этого:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let diceRoll = Int(arc4random_uniform(2) + 1)
var cell = collectionView.dequeueReusableCellWithReuseIdentifier("profileViewCell", forIndexPath: indexPath)
if(diceRoll == 1) {
cell = collectionView.dequeueReusableCellWithReuseIdentifier("profileChartViewCell", forIndexPath: indexPath)
}
return cell
}
Как я могу получить reuseIndentifier текущей ячейки, так что я могу изменить высоту в зависимости от того, какого типа клетки это?