I have specific problem regarding a library I am using for displaying images in UIPageViewController
which I have added in a UICollectionView
, this is the library that I am using, all my work is done through this library on first viewDidLoad
, but problem occurs when I scroll up and down the CollectionView, it gets keep repeating the images in that UIpageViewController
, following is my piece of code where I am having issue.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell: FeedsCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "FeedsCollectionViewCell", for: indexPath) as! FeedsCollectionViewCell
if postObject.contents.count > 0 {
for content in postObject.contents {
cell.feedImageHeightConstaint.constant = 200
cell.carouselViewHightContaint.constant = 200
let imageSlide = UIImageView()
let tap = UITapGestureRecognizer(target: self, action: #selector(showImage(_:)))
imageSlide.isUserInteractionEnabled = true
imageSlide.addGestureRecognizer(tap)
imageSlide.contentMode = UIView.ContentMode.scaleAspectFill
imageSlide.clipsToBounds = true
imageSlide.sd_setImage(with: URL(string: content.contentURL!), placeholderImage: nil) { [weak self](image, error, imageCacheType, url) in
guard let self = self else { return }
self.popUpFeedImage = image
}
cell.carouselView.appendContent(view: imageSlide) }
}
now i think i know that issue is this library has only append function but this function is not removing its values on new object creating, I have tried fixing it but I couldn't achieved it, so I am posting if here for any help that I can get would be appreciated. For more detail of understanding my issue, sharing a gif bellow.