Thanks for the suggestions. I've been playing around with a subclass, VOFriendlySlider, for a few days now, and it's partly working. The main three problems are:
* I use a switch in accessibilityScroll(direction), and print statements tell me that my scrolls are detected properly. However, VO just plays an error sound and the slider doesn't move. I'll paste the code below. * When I increment/decrement with one finger using VO's "adjust value" rotor item, the accessibility value is set as I've told it to be. However, the actual slider doesn't change, even though I set the "value" property. I'll paste my increment method below. Note that if I add a call to super.accessibilityIncrement in my override, the slider does indeed update as expected, but the amount by which it increments is back to the default and not the one I've set. * If I double tap and hold on a slider, then move my finger to change the value that way, the slider changes. The accessibilityValue property, though, doesn't change. Is overriding the series of touch methods in UIControl the best way to fix this one?
Now, my code. Sorry in advance for how it looks, I'm not exactly a professional. :P the stepGroups thing is an idea I had where the user could scroll left or right to move between groups. Each group lets one- or three-finger adjustments move by a different amount, so an app could offer fine up to gross adjustments. The user could choose between the level of control s/he wants by scrolling left o right. For our purposes, just assume all the stepGroups stuff holds valid float values. In fact, Apple probably wouldn't like this idea, since it's not "normal" interaction. Anyway…
override func accessibilityIncrement() { if let incrementValue=stepGroups[currentStepGroupIndex].smallIncrementValue { self.value+=incrementValue } else { self.value+=stepGroups[currentStepGroupIndex].defaultStepValue } updateAccessibilityValue(nil) } func updateAccessibilityValue(val:String?) { if let newAccessibilityValue=val { self.accessibilityValue=newAccessibilityValue } else { self.accessibilityValue="\(self.value) of \(self.maximumValue)" } }
override func accessibilityScroll(direction: UIAccessibilityScrollDirection) -> Bool { //for three-finger swipes print("Scroll detected. Direction: \(direction)") switch direction { case UIAccessibilityScrollDirection.Left: print("scroll left") if capturesLeftAndRightScroll { currentStepGroupIndex-=1 return true } return false case UIAccessibilityScrollDirection.Right: print("scroll right") if capturesLeftAndRightScroll { currentStepGroupIndex+=1 return true } return false case UIAccessibilityScrollDirection.Up: print("scroll up") if capturesUpAndDownScroll { largeDecrement() return true } return false case UIAccessibilityScrollDirection.Down: print("scroll down") if capturesUpAndDownScroll { largeIncrement() return true } return false default: print("unrecognized scroll") return false } }
On Jul 4, 2015, at 7:30 PM, Boris Dušek < email@hidden> wrote:
Yes, simply subclass. You can then use the name of the subclass in Interface Builder (Identity Inspector > Custom class > class) in case you are creating your UI there. If you are instead creating the UI in code, just change the name of the class you are instantiating.
accessibilityScroll does get passed up the responder chain, so it would reach your view controller eventually if the specific direction is not handled on the slider (unless another view in the responder chain before, like a vertical scroll view, handles vertical scrolling in the relevant direction itself), but still, as you say, you will not get information about *which* slider got scrolled.
So back to the beginning: just subclass, and cope with the usual “hard" problem how to name the subclass :-)
Btw. I now realized you will certainly find the WWDC 2014 “Accessibility in iOS” session interesting, especially since time position 35:12.
Best regards, Boris On Jul 5, 2015, at 12:47 AM, Alex Hall < email@hidden> wrote:
This is exactly it, thank you! I'm stuck, though: how do I implement this? I know what to do inside the function, but I'm not sure how to attach it to my slider. I see two ways: a separate view controller file for each slider, or a custom subclass of UISlider. The more I think about it, the more sense the latter option makes. Is there an easier way I'm missing, though--a way to keep all this in my single view controller? As I said, I use three sliders, so I need to know which slider was moved and act only on that one, but accessibilityIncrement/Decrement take no arguments. Is a subclass the best way to do this? On Jul 4, 2015, at 5:44 PM, Boris Dušek < email@hidden> wrote:
“one more thing” To change what three-finger swipe does, override accessibilityScroll, checking for the up/down scroll directions and handling those.
don’t forget to return true (YES) for the directions you handle (support) and false (NO) for the directions you do not handle (do not support).
--
Have a great day, Alex Hall
--
Have a great day, Alex Hall
|