Search code examples
iosuislider

display the value while the user slides


please i recently have maked a slider which allow user to select the radius of the search algorithm in KM, i just need to display the value of this slider while the user slides like shown in this demonstration ( http://www.youtube.com/watch?v=FEAkVCouI_Y) or even as a small popup message above the slider showing the value(which will be more professional i guess), thx in advance :)))


Solution

  • You need to setup UISlider property, named "continuous". As it is told in documentation: "If YES, the slider sends update events continuously to the associated target’s action method. If NO, the slider only sends an action event when the user releases the slider’s thumb control to set the final value.

    The default value of this property is YES."

    (I wonder, why it is disabled if the default value is "YES"?)

    Second, you'll have to add a target to a UISlider object. You can do it with addTarget:… message:

    - (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
    

    As far as I remember, you need UIControlEventValueChanged control event type.