about showing continuous slider value in UISlider

核能气质少年 提交于 2019-12-03 13:06:11

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!