Detecting touches on a UISlider?

后端 未结 3 1189
南笙
南笙 2020-12-18 22:40

I have a UISlider on screen, and I need to be able to detect when the user stops touching it. (so I can fade some elements away).

I have tried using:

-

3条回答
  •  天命终不由人
    2020-12-18 23:18

    You can detect when a touch ends using two control events; try

    [slider addTarget:self action:@selector(touchEnded:) 
                           forControlEvents:UIControlEventTouchUpInside];
    

    or

    [slider addTarget:self action:@selector(touchEnded:) 
                           forControlEvents:UIControlEventTouchUpOutside];
    

    If you want to detect both types of the touchesEnd event, use

    [slider addTarget:self action:@selector(touchEnded:) 
       forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
    

提交回复
热议问题