Krimi
Krimi

Reputation: 332

UICollectionView display previous cell content in next cell while scroll horizontally

I am using a UICollectionView to show an array of images, horizontally and zoom in/out that image in the cell with the help of scroll view using constraints. But when I scroll horizontally it shows me previous cell content in the current cell. I am and not able to identify what is the problem. enter image description here

enter image description here

CollectionView datasources

enter image description here

CollectionCell Class enter image description here

Upvotes: 0

Views: 600

Answers (3)

Andy Darwin
Andy Darwin

Reputation: 478

The contentSize of the scrollView should be as big as imageView.image.size, or just use MWPhotoBrowser

Upvotes: 0

Mehul Parmar
Mehul Parmar

Reputation: 3699

Please share some code so that we can help you better. Meanwhile, make sure you have the following parts working correctly in your code:

  • Register correct UICollectionViewCell subclass with correct reuse identifier

  • Use the method [self.collectionView dequeueReusableCellWithReuseIdentifier:itemIdentifier forIndexPath:indexPath] and pass both the parameters correctly.

  • In UICollectionViewCell subclass, override prepareForReuse and reset the UI parameters there.

    Override prepareForReuse in imageCell class, and set imageView.image to nil.

Upvotes: 0

Manvir Singh
Manvir Singh

Reputation: 139

try this when you reuse the Cell in cellForItem at

cell.imageView.Image = nil

Upvotes: 0

Related Questions