Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable cell reuse on UICollectionView

I am using a UICollectionView in my app with gesture recognizers on the individual cells which allow the user to "slide open" the cell to reveal more data underneath.

The problem is, I am reloading the data in the CollectionView very often; as the app receives updates once every 3 seconds or so. This results in unwanted behavior with the collectionview cells being reused while a cell is in the process of being slid.

The user will start to slide a cell, the app will receive an update, reloadData, and a different cell will start receiving the gesture instead, and begin sliding.

I have tried disabling the app's updates while the slide is occurring, but that caused other complications within the app, so I am wondering if there is a way to disable the cell reuse, (I will only have 20 cells max, so I don't think there would be a large drop in performance).

Thank you!

like image 863
dKrawczyk Avatar asked Nov 14 '12 16:11

dKrawczyk


1 Answers

Why don't you use a flag like needsReload and set it, if new data is available. After a slide you check for that flag and reload the collectionView, if needed? Is this not working?

If you don't want cell reusing, just use a default scrollView and put all your views in it!?

like image 89
calimarkus Avatar answered Oct 06 '22 03:10

calimarkus