Ios 如何避免UICollectionView在swift中重复单元格

Ios 如何避免UICollectionView在swift中重复单元格,ios,swift,uicollectionview,uicollectionviewcell,Ios,Swift,Uicollectionview,Uicollectionviewcell,你好,我有一个UICollectionView。我从一个NSMutableArray加载数据,它有两个对象。但我的问题是它再次重复相同的细胞 我正在使用XIB文件和swift代码,有人能帮我吗 func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { return 1 } func collectionView(collectionView: UICollectionView

你好,我有一个
UICollectionView
。我从一个
NSMutableArray
加载数据,它有两个对象。但我的问题是它再次重复相同的细胞

我正在使用
XIB
文件和swift代码,有人能帮我吗

func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {

    return 1
}

func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return (contentImagesLsit?.count)!
}

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

    self.collectionView.registerNib(UINib(nibName: "GridCell", bundle: nil), forCellWithReuseIdentifier: "Cell")
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! GridCell
    print((contentImagesLsit?.objectAtIndex(indexPath.row) as? StylistMedia)!.imageURl)
    cell.imageCell?.setImageWithURL(NSURL(string: (contentImagesLsit?.objectAtIndex(indexPath.row) as? StylistMedia)!.imageURl), placeholderImage: nil, usingActivityIndicatorStyle: UIActivityIndicatorViewStyle.Gray)

    return cell
}
这是我的模拟器输出


不在
集合视图:cellForItemAtIndexPath:
中注册nib。
contentImageLsit
对象是否不同?@venky Siddani请检查您的数组数据。可能是您填写了相同的数据两次。谢谢,数据是正确的,它来自数据库。如果您使用的是UICOLLECTION视图和XIB文件,请不要在
collectionView:cellForItemAtIndexPath:
中注册nib,任何人都可以将代码或教程发送给我。
contentImageLsit
对象是否不同?@venky Siddani请检查您的数组数据。可能是您填写了相同的数据两次。谢谢,数据是正确的,它来自数据库。如果您使用的是UICOLLECTION视图和XIB文件,任何人都可以向我发送代码或教程吗