I have a CollectionView with multiple cell types. When scrolling between different cell types performance can get very laggy. I'm not exactly sure how to fix it. Here's my cellForItemAtIndexPath:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
if cellType == "imageCell" {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("iCell", forIndexPath: indexPath) as! ImageCell
//do things for cell
return cell
}else if cellType == "mapCell" {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("mCell", forIndexPath: indexPath) as! MapCollectionViewCell
//do things for cell
return cell
}else if cellType == "pCell" {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("pCell", forIndexPath: indexPath) as! PCell
//do things for cell
return cell
}else if cellType == "detailCell" {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("fCell", forIndexPath: indexPath) as! DetailCell
//do things for cell
return cell
}else{
return UICollectionViewCell()
}}
Aucun commentaire:
Enregistrer un commentaire