UISlider事件 [英] UISlider events
问题描述
我正在使用UISlider,它自动更新,除非用户正在触摸滑块。因此我在NSTimer自动更新的功能中执行了此操作:
if(!isSliderTouched){
[progressSlider setValue:progressValue];
}
当用户释放手指时,如何跟踪此事件的结局。只要用户与此控件进行交互,我想设置isSliderTouched。
编辑:这应该是情节:
- 用户开始浏览/触摸UISlider => isSliderTouched = YES
- 用户发布/未触摸
UIControlEventTouchDown
UIControlEventTouchUpInside
[progressSlider addTarget:self action:@selector(sliderMoveStart)forControlEvents:UIControlEventTouchDown];
cheers endo
解决方案您可以使用:
- (void)addTarget:(id) action forControlEvents:(UIControlEvents)controlEvents
检测
touchDown
和touchUp
事件发生。您可以相应地设置您的标志。
我从您的代码段猜测您使用UISlider作为进度表。你考虑过使用UIProgressView吗?
I'm using an UISlider, its updated automatically except the user is touching the sliderbutton. therefore i did this in the function which updates automatically by an NSTimer:
if (!isSliderTouched) { [progressSlider setValue: progressValue]; }
How do I track the ending of this event, when the user releases his finger. I want to set isSliderTouched as long as the user interacts with this control.
EDIT: this should be the plot:
- user beginns draging/touching UISlider => isSliderTouched = YES
- user releases/untouch the UISlider => isSliderTouched = NO
Solution:
UIControlEventTouchDown UIControlEventTouchUpInside [progressSlider addTarget:self action:@selector(sliderMoveStart) forControlEvents:UIControlEventTouchDown];
cheers endo
解决方案You can use:
- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
to detect when the
touchDown
andtouchUp
events occur. You can set your flag accordingly.I'm guessing from your code snippet that you are using a UISlider as a progress meter. Have you considered using a UIProgressView instead?
这篇关于UISlider事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!