i am using a collectionview inside a tablview cell, in which collectionview cells are having an imageview on which images are displaying from the array of URLs in cellForItemAtIndexPath. I am calling webservice inside tableview cell class to getting array of URLs. My problem is that whenever i scrolls down or up tableview, collectionview cells are repeating, images of collectionview are repeating itself. so how to get rid out of this.
My Code is as follows -
inside response of webservice
let imgList : NSArray = arrReponseDetails.value(forKey: "imageList") as! NSArray
self.arrImgUrls.removeAll()
for dict in imgList[0] as! NSArray {
let dictionary = dict as! NSDictionary
let strUrl : String = dictionary["url_highRes"] as! String
let url : URL = URL(string: strUrl)!
self.arrImgUrls.append(url)
}
self.collectionView.reloadData()
code inside of cellForItemAtIndexPath
let cell : CollectionCell = collectionView.dequeueReusableCell(withReuseIdentifier: "CollectionCell", for: indexPath) as! CollectionCell
let url : URL = self.arrImgUrls[indexPath.row]
cell.imgSticker.sd_setShowActivityIndicatorView(true)
cell.imgSticker.sd_setIndicatorStyle(.gray)
cell.imgSticker.sd_setImage(with: url, placeholderImage: nil)
cell.imgSticker.contentMode = .scaleAspectFit
return cell