I can detect the value change event from the UISlider, but now I need to detect a user releasing 开发者_Go百科the slider button.
How to detect this event (or touch on slider ends) ?
Should I use the "touch up inside" event for detection ?
Thanks.
You can also use the UISlider's UIControlEventValueChanged
. Set the continuous
property to NO as to initiate when the user is done selecting a value.
[mySlider addTarget:self action:@selector(myMethod) forControlEvents:UIControlEventValueChanged];
mySlider.continuous = NO;
I've not worked with sliders, however as UISlider inherits from UIView - surely you can just tap into touchesBegan: and touchesEnded: to perform your task.
Through IB you can attach "Touch Up Inside" and "Touch Up Outside" to a method/action of the viewController for slider release.
Or more programmatically (probably in your viewController), you can use
- (void)addTarget:(id)target action:(SEL)action
forControlEvents:(UIControlEvents)controlEvents
to detect when the UIControlEventTouchUpOutside
and UIControlEventTouchUpInside
events occur to your UISlider.
References
- method
- control events
UIControlEventTouchDown
event to detect when the user starts using the control. UIControlEventTouchUpInside
when the user finishes using the slider. To add the event just do as @JohnK suggested
精彩评论