开发者

about showing continuous slider value in UISlider

开发者 https://www.devze.com 2023-03-10 17:32 出处:网络
Here\'s what I want to do with UI Slider .... I have a bunch of files with times and I show them based on slider value. The p开发者_如何学Pythonroblem is I want to show the slider value when the user

Here's what I want to do with UI Slider ....

I have a bunch of files with times and I show them based on slider value. The p开发者_如何学Pythonroblem is I want to show the slider value when the user is changing/moving the slider. In other words, the value should change (and be shown on the screen) as the user is moving the slider (and not afterwards).

Can anyone please give me any idea how to do it ?

Thanks.


You can ask to get a method called when the slider's value changes. Then using that change, you should update the text of a label.

To listen for the value's change:

[mySlider addTarget:self action:@selector(mySliderChanged:) forControlEvents:UIControlEventValueChanged];

Then to update the label:

NSString *labelString = [NSString stringWithFormat:@"Slider value is %d", mySlider.value];
[myLabel setText:labelString];


UISlider class docs

mySlider.continuous = YES;


@property(nonatomic, getter=isContinuous) BOOL continuous

from docs:

Discussion

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.

0

精彩评论

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

关注公众号