Skip to content
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

Bug when setting lower and upper bounds in a specific order #66

Open
fmaylinch opened this issue Nov 4, 2015 · 7 comments
Open

Bug when setting lower and upper bounds in a specific order #66

fmaylinch opened this issue Nov 4, 2015 · 7 comments

Comments

@fmaylinch
Copy link

I've seen that there's a bug when setting values like these:

    hourSlider.minimumValue = 6
    hourSlider.maximumValue = 23
    hourSlider.lowerValue = 6
    hourSlider.upperValue = 23

It seems that the setter for lowerValue limits the value to current upperValue(which is 1.0 by default) so lowerValue ends up being 1.0 too. But since the minimumValue is 6 you get a wrong slider.

It works if I set the values in this order:

    hourSlider.maximumValue = 23
    hourSlider.minimumValue = 6
    hourSlider.upperValue = 23
    hourSlider.lowerValue = 6
@astanton
Copy link

astanton commented Nov 7, 2015

Thanks a bunch for posting this. I just spent an hour trying to figure out if I was going crazy or not with things working a certain way and not in other instances lol. I did what you said and it's working as expected.

Really surprised this isn't a standard iOS control. This is the best one that I found by far because it is styled to look like the other controls on iOS.

@muZZkat
Copy link
Owner

muZZkat commented Nov 7, 2015

Sorry, I've been meaning to fix this bug for a while!

@p-antonelli
Copy link

First, thanks a lot for this useful component, that should have been a standard control in my opinion,
This is just a small bug, but really annoying in my case

I faced the same problem for several hours, going mad trying to reload the cell containing the control in every moment possible.... :(, but hopefully found this solution xD

Special thanks to fmaylinch for finding the good sequence of setting values :)

@luantlai
Copy link

this bug is at line 139 of NMRangeSlider.m:

value = MIN(value, _upperValue - _minimumRange);

when you set the lowerValue, the default _upperValue has not been set yet, it still 1.0 by default
So I fixed this by calling set value 2 times, the first time should have no animated:

    rangeSlider.setLowerValue(Float(lowerValue), upperValue: Float(upperValue), animated: false)
    rangeSlider.setLowerValue(Float(lowerValue), upperValue: Float(upperValue), animated: false)

@sreid768
Copy link

I've created a Pull Request that resolves this issue.

Fixed bug when setting lower and upper bounds in a specific order

@Mov1s
Copy link

Mov1s commented Apr 12, 2016

Oh my god, thank you for pointing this out, this caused me a huge headache. Thanks for the control @muZZkat !

@sreid768
Copy link

Haha no worries. Just waiting for it to be integrated into the master branch. Let me know if it works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants