New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to setup HCSStarRatingView view in UICollection view cell Swift? #58
Comments
That code should work to properly configure the rating view in a cell. Are you sure you're not doing anything else to that cell or the rating view when the collection view scrolls? |
Yes, thats all i have done. |
Hi hsousa, But I have one confusion. I am using this same rate UI in table cell to display rating done by users and also to rate from it. I allow minimum value user can set as 1 and does allow half rating. So users will not be able to rate below 1, but will be able to rate as 1.5 value. Thats working fine. Not a problem. |
Interesting, I never really thought about the scenario you're describing, where the initial value might be different than the one allowed to be input by the user. To be honest, this is actually something that would make sense to be added to As a temporary workaround, how about this:
@interface CustomStarRatingView : HCSStarRatingView
@property (nonatomic) CGFloat minimumValueAfterTouches;
@end
@implementation CustomStarRatingView
- (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event {
// This ensures you only do this when the base class allows tracking to begin
if ([super beginTrackingWithTouch:touch withEvent:event]) {
self.minimumValue = self.minimumValueAfterTouches;
}
return NO;
}
@end * I didn't actually test any of this 😂 |
Thanks hsousa for the response. |
My pleasure! |
Hello friends,
I am having problem using HCSStarRatingView in UICollection Cell.
How to setup HCSStarRatingView view in UICollection view cell Swift 3?
HCSStarRatingView star value set keeps on changing when rating view in UICollectionView Cell and collection view is scrolled.
I added HCSStarRatingView on UICollection View Cell in storyboard.
Created strong outlet of HCSStarRatingView as
@IBOutlet var ratingView: HCSStarRatingView!
Then in collection view cell for index path code is like this.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = self.collectionVC.dequeueReusableCell(withReuseIdentifier: "collectionCell", for: indexPath as IndexPath) as! CustomCollectionViewCell
cell.ratingView.value = (self.ratingValueDataArray.value(forKey: "rating") as AnyObject).object(at:indexPath.row) as! CGFloat // setting rating value from JSON array response.
return cell
}
However, for first time value is set on rating view correctly. But on collection view scroll the value is changed on random manner.
Any help?
Thanks
The text was updated successfully, but these errors were encountered: