In my application, there is a UISlider which is only slidable after a long-press (let's say, after 0.1 seconds of the press). To prevent from the slider to interact immediately, I set mySlider.isUserInteractionEnabled = false
as default. However, since .isUserInteractionEnabled
will disable all the functions, including the long-press gesture, I use another transparent UIButton
of the same size as the slider on the top of it to detect long-presses, and set mySlider.isUserInteractionEnabled = true
in the callback action. This works fine, except that the UIButton
must be released first and then the user tap the slider again to slide it instead of drag the slider directly within the same touch. This make the slider very inconvenient to use. Therefore, I would like to know if either:
- There is a better way other than mine to make UISlider start sliding only after certain delay? I'm quite surprised that I couldn't find any solution on this. I thought this would be a common need for a slider to be locked at a certain point.
or
- Following my solution, is there any way that I could start dragging the slider thumb within the same touch?
Thanks a lot for any kind of answer.
Added: My solution looks like the following: in the TableViewCell
, there is a label, a slider, and an invisible button with the same size as the slider (The grey background area). I set slider attribute isUserInteractionEnabled == false
, and then add gesture recogniser to manipulate the slider (such as single tap, double tap for my custom functions, and long-press gesture which enable the slider). After the button is long-pressed, the isUserInteractionEnabled
of the slider will set to true until the thumb goes to the new value.
Basically I only want to disable the slider to respond too quickly for short taps, the other features of the slider would remain the same. I suppose there may be better ways to achieve this, the so far using an transparent button is the only way I could think of.