How to set the slider to clicked position and get the slider value on the clicked location on UISlider in iPhone programming. i know we can drag the slider to that position but i dont want to do it. Can you please tel me how to set the slider to clicked position? Is this possible to do?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- Could I create “Call” button in HTML 5 IPhone appl
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Open iOS 11 Files app via URL Scheme or some other
- Can keyboard of type UIKeyboardTypeNamePhonePad be
- Can not export audiofiles via “open in:” from Voic
- XCode 4.5 giving me “SenTestingKit/SenTestKit.h” f
I was using the subclassed UISlider code to listen to ValueChanged events in ios6> in order to implement a snap-to-grid type of function.
This was broken when upgrading to iOS7 as it no longer fired the UIControlEventsValueChanged. For anyone having the same problem it is fixed by adding a line in the if() as below:
Hope it helps someone :)
Here is the part "left as a user exercise":
The way I did it is to subclass the slider and check in
touchesBegan
. If the user taps on the thumb button area (which we track) then ignore the tap, but any where else on the trackbar we do: :I have used this code. Get from: http://imagineric.ericd.net/2012/11/15/uislider-touch-to-set-value/
Hope this can help you.
You can simply add a UITapGestureRecognizer to the slider, then pull out the UIEvent and Touches associated with it to figure out where along the UISlider the tap took place. Then set your slider's value to this calculated value.
UPDATE:
First, setup your slider and add the gesture recognizer to it.
Then implement the selector
*Hint: Read the docs to figure out how to get the locationInView extrapolated and figure out what the slider should be
It seems like just subclassing UISlider and returning always true to the beginTracking produce the desired effect.
iOS 10 and Swift 3