开发者

UIslider increase 10 by 10

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] in开发者_Python百科itWithFormat:@"annonce:%d",(int)sliderannonce.value];

}

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


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;


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);

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜