1

I added a UISlider in interface builder in my iOS application. Can I make it so that the user can see the value of a UISlider while he/she is altering it?

Is there an interface builder setting I can change to easily implement this, or must I implement an IBAction that alters a UILabel on the screen based on the slider's value?

Justin Copeland
  • 1,891
  • 5
  • 23
  • 27

2 Answers2

2

Connect the UISlider's valueChanged selector to your custom IBAction and set some UILabel's value in that method

tipycalFlow
  • 7,594
  • 4
  • 34
  • 45
  • Thanks, I can associate an IBAction to that selector. However, is there a way to do this through the interface builder? – Justin Copeland Apr 02 '12 at 06:33
  • Ofcourse...take a look at [this question](http://stackoverflow.com/questions/9554121/connect-object-in-xib-to-existing-ibaction/9554230#9554230) with images – tipycalFlow Apr 02 '12 at 06:35
  • Oh, ok thanks. I meant setting the slider to change directly in the interface builder. However, your method certainly works. Thanks! – Justin Copeland Apr 02 '12 at 06:36
  • you can set a default value but not slide the slider in your `xib` like you would in the app! – tipycalFlow Apr 02 '12 at 06:38
1

Yes there is. You can set an outlet of type

    IBOutlet UISlider *slider

in your view controller, then bind it to the slider. Then the value of the slider is always accessible through the slider.value property, even in other methods.

Jorge Aguirre
  • 2,787
  • 3
  • 20
  • 27