【发布时间】:2019-06-03 21:53:07
【问题描述】:
我有一个关于我用于在UIPageViewController 中显示图像的库的具体问题,我在UICollectionView、this is the library 中添加了我正在使用的库,我所有的工作都是通过这个库首先完成的@987654326 @,但是当我向上和向下滚动 CollectionView 时会出现问题,它会不断重复 UIpageViewController 中的图像,以下是我遇到问题的一段代码。
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) }
}
现在我想我知道问题是这个库只有 append 函数,但是这个函数不会在创建新对象时删除它的值,我已经尝试修复它但我无法实现它,因此,如果我能在这里获得任何帮助,我将不胜感激。 有关了解我的问题的更多详细信息,请在下面分享 gif。
【问题讨论】:
标签: ios swift uicollectionviewcell uipageviewcontroller reuseidentifier