简体   繁体   中英

iOS UISlider - change price value

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!

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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM