Detecting touches on a UISlider?

后端 未结 3 1187
南笙
南笙 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:04

    Instead of using touchesEnded: (which shouldn't be used for this purpose anyway), attach an action to the UISlider's UIControlEventValueChanged event and set the continuous property of the UISlider to NO, so the event will fire when the user finishes selecting a value.

    mySlider.continuous = NO;
    [mySlider addTarget:self
              action:@selector(myMethodThatFadesObjects) 
              forControlEvents:UIControlEventValueChanged];
    

提交回复
热议问题