evgenyneu / Cosmos

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

Touch Doesn't update rating right away #86

Closed normdoow closed 6 years ago

normdoow commented 6 years ago

Hello,

First of all, thanks for making a cool library. I am on Xcode 9, Cosmos version 12.0.1 on iOS 11. The setup and everything seems to work well, but I am having an issue where once the view is pulled up with the stars, the touches don't make the rating change right away. It seems like it takes 10 seconds or so before it recognizes the rating change on the UI. This may be that the hit box is small or something like that and it just takes around that long to hit it.

I am not doing anything special. Just have a nib with the Cosmos in it and only changing the settings.starSize to 55.

Here is all of my code in the View Controller. The rest of the setup is in Storyboards.

override func viewDidLoad() {
        super.viewDidLoad()
        starRatingView.settings.updateOnTouch = true
        starRatingView.settings.fillMode = .full
        starRatingView.settings.starSize = 55

    }

Thanks!

evgenyneu commented 6 years ago

Hi @normdoow, thanks for reporting the issue. I could not reproduce your problem. I created a new project and used your viewDidLoad code. Tested in iOS 11 simulator. Please find the project attached and let me know how it goes.

DemoCosmos.zip

normdoow commented 6 years ago

Thanks for the reply @evgenyneu. I tried out the demo and it worked. the only difference I saw in yours compared tom mine was that you had constraints on the CosmosView. Once I added constraints to mine it worked as well. I'm not sure if that is an issue or if it is expected that constraints are put on the view. Thanks!

evgenyneu commented 6 years ago

I'm glad it worked.

Once I added constraints to mine it worked as well.

Oh, this is interesting. I'm not sure why it did not work without constants. I've removed the constraints from the view and it still works without delays. Weird... See the demo app attached.

DemoCosmosNoConstraints.zip

normdoow commented 6 years ago

hmm, I may have messed up the view width and height some how. Its working now though. Thanks

evgenyneu commented 6 years ago

Oh, actually, if you were setting the width or height for the Cosmos view before, that might be the reason why it did not work well. Cosmos view sets its width and height automatically based on the stars inside. Just a like a text label.