0

I've been looking for quite some time for a solution but couldn't find the right answer for me.

I'm trying to set two sliders - one for minimum price and one for maximum price, and then create labels that will contain the prices. Both sliders will change the labels' values accordingly. I've yet to find a good way to display a price and alter it with the sliders, could you please help me?

Thank you and I'm truly sorry if this is a stupid question, I have just started iOS a few weeks ago. Thanks a bunch!

1
  • Just review the basic examples and coco for UISlider, cheers. You can do it all easily in XIB.
    – Fattie
    Mar 1, 2014 at 13:58

2 Answers 2

2

If you would Google for basic examples first, you would find these resources:

So what you have to do is follow the steps below:

  1. Create both UISlider's and UILabel's on Storyboard/Interface Builder.
  2. Connect them with code in your View Controller as IBOutlet's.
  3. Add Target actions to UISlider's - UIControlEventValueChanged.
  4. Update UILabel's text when that target action is fired.

While this seems much, it is practically a very basic iOS development technique. View the links above for more detailed explanation.

And remember, always do your own research first, before presenting a problem to StackOverflow. This question is very basic and every programmer should be able to solve it, without asking others to solve it for you.

2
  • Thank you for the reply and for the info. But that's not what i meant exactly. I got all the stuff you said working, my issue is different. I couldn't find a good way to show a label with a price (could be just a normal int) in relation to the sliders value (that ranges between 0.0-1.0). I understand the confusion my post made. But I just asked for a help with a good representation for the price through the sliders value. I googled that before I asked but I couldn't find something to answer my issue. thanks again tho.
    – GalSab
    Mar 1, 2014 at 14:19
  • If you have slider's value between 0.0 and 1.0, you can get your label's value with the following code: label.text = [NSString stringWithFormat:@"%f", (minimumValue + (maximumValue - minimumValue) * slider.value];
    – Legoless
    Mar 2, 2014 at 14:01
0

you can set the maximumValue property of UISlider, if you set maximumValue is 1000,then the ranges of slider`s value is 0~1000.

is this your problem?

1
  • This is what I meant since in the documentation i saw 0.0-1.0. anyway now it worked so thanks!
    – GalSab
    Mar 4, 2014 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.