This is the valueChanged voids for my two UISliders. Their function is to set the minimum and maximum price for objects. What I cannot figure out it how to make them not exceed each others values.
So if minPrisSlider.value = 100, it should not be possible to drag the maxPrisSlider below 100 and opposite.
- (void)minValueChanged:(UISlider*)sender
{
NSUInteger index = (NSUInteger)(minPrisSlider.value + 0.5); // Round the number.
[minPrisSlider setValue:index animated:NO];
int progressAsInt =(int)(minPrisSlider.value + 0.5f);
NSString *newText =[[NSString alloc] initWithFormat:@"%d,-",progressAsInt];
minPrisText.text = newText;
}
- (void)maxValueChanged:(UISlider*)sender
{
NSUInteger index = (NSUInteger)(maxPrisSlider.value + 0.5); // Round the number.
[maxPrisSlider setValue:index animated:NO];
int progressAsInt =(int)(maxPrisSlider.value + 0.5f);
NSString *newText =[[NSString alloc] initWithFormat:@"%d,-",progressAsInt];
maxPrisText.text = newText;
}
I have tried adding
[minPrisSlider setMaximumValue:maxPrisSlider.value]; in maxValueChanged
and
[maxPrisSlider setMinimumValue:minPrisSlider.value]; in minValueChanged
but it returns strange results…
Got some working solution for this?
The thing is, the slider’s thumb position is proportional to its maximum/minimum value. So setting the maximum/minimum value shouldn’t do
In your case, you should try this :
And reverse it for the max slider. Don’t forget to set the continuous value :