I have the following code, which puts a collection view into either one or two columns, depending the size of the screen:
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)
}
I would like to amend this, so the height is dependent upon the reuseIdentifier. There are two I use - set something like this:
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
}
How can I get the reuseIndentifier of the current cell, so that I can change the height depending on what type of cell it is?