UISlider事件 [英] UISlider events

查看:292
本文介绍了UISlider事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UISlider,它自动更新,除非用户正在触摸滑块。因此我在NSTimer自动更新的功能中执行了此操作:

  if(!isSliderTouched){
[progressSlider setValue:progressValue];
}

当用户释放手指时,如何跟踪此事件的结局。只要用户与此控件进行交互,我想设置isSliderTouched。



编辑:这应该是情节:


  1. 用户开始浏览/触摸UISlider => isSliderTouched = YES

  2. 用户发布/未触摸



      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:

    1. user beginns draging/touching UISlider => isSliderTouched = YES
    2. 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 and touchUp 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆