evgenyneu / Cosmos

A star rating control for iOS/tvOS written in Swift
MIT License
2.19k stars 368 forks source link

Table view cleans starts on scroll #120

Closed sashberd closed 6 years ago

sashberd commented 6 years ago

Please consider submitting the following information (if relevant):

Hi,

I have a problem with you lib and table view. When table view is scrolled the rating is resets to one\ ezgif com-video-to-gif

Even if I remove Can Cancel On Scroll option it is still has same issue.

Am I miss something, maybe such issue was already resolved here?

Thanks

evgenyneu commented 6 years ago

Hi @sashberd, thanks for reporting. This could be caused by the way table view reuses cells. Table view does not keep all the cells in memory, only those that are visible. One approach is to save rating when it is updated by the user in some storage and then use this storage to initialize the cells as they are added.

The demo app contains an example of that: https://github.com/evgenyneu/Cosmos/blob/master/Demo/PerformanceTableViewController.swift

Let me know if it helps.

sashberd commented 6 years ago

@evgenyneu Thanks for such rapid answer, I will check it out and will give you to know

sashberd commented 6 years ago

@evgenyneu You solution is worked for me thanks!!!