在一个CollectionVIew中具有多个UICollectionViewCell的性能不佳

时间:2015-04-26 12:50:59

标签: ios swift uicollectionview

我有一个包含多种细胞类型的CollectionView。在不同单元格类型之间滚动时,性能可能会非常滞后。我不确定如何解决它。这是我的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()
        }}

0 个答案:

没有答案