views:

32

answers:

2

I'm making an UISlider and I don't find how to change the selectable values, I would like the only values possible be 10 by 10. The slider begins at 82 and ends at 362. I want the possible value to be 82,92,102,.....

I've tried different things but I don't find

[sliderannonce setValue: [sliderannonce value]+10.0 animated:YES];

or

sliderannonce.value=10;

I've my action here:

- (IBAction)changeSliderAnnonce:(id)sender{

 labelSliderAnnonce.text = [[NSString alloc] initWithFormat:@"annonce:%d",(int)sliderannonce.value];

}

If you did something like that or you know how to do please let me know.

+2  A: 

Wouldn't it be simpler to just multiply the value by 10 in your code and add the starting value?

Example : start the slider at 0, end at 28 :

int position = 82 + ((int)sliderannonce.value) * 10;
jv42
A: 

Finally found a way to "cheat" with your idea thanks :D I started to 8,2 and end to 36,2 and I multiply by 10

- (IBAction)changeSliderAnnonce:(id)sender{

    int position= ((int)sliderannonce.value)*10+2;
    labelSliderAnnonce.text = [[NSString alloc] initWithFormat:@"annonce: %d",((int)sliderannonce.value)*10+ 2];


    NSLog(@"valeur de l'enchere: %d",position);

}
ciwol