I have a UITextView
with two different hyperlinks in it. To give the chance to choose between the two links when VoiceOver is on, I did:
class MyTextView {
override func awakeFromNib() {
super.awakeFromNib()
let str = "xxxxxx Option 1 yyyy Option 2"
let attrStr = NSMutableAttributedString(str)
let rangeOption1 = (str as NSString).range(of: "Option 1")
let rangeOption2 = (str as NSString).range(of: "Option 2")
attrStr.addAttributes([.link: "option1", range: rangeOption1])
attrStr.addAttributes([.link: "option2", range: rangeOption2])
self.attributedText = attrStr
}
override var isAccessibilityElement: Bool {
get { return true }
set {}
}
override var accessibilityLabel: String? {
get { return "Link Options" }
set {}
}
override var accessibilityCustomActions: [UIAccessibilityCustomAction]? {
get {
return [
UIAccessibilityCustomAction(name: "Choose Option One", target: self, selector: #selector(option1)),
UIAccessibilityCustomAction(name: "Choose Option Two", target: self, selector: #selector(option2))]
}
set {}
}
@objc func option1() { print ("Option 1") }
@objc func option2() { print ("Option 2") }
}
I did this following this WWDC video from min 33. What I can not manage is that it says Swipe Up or Down to Select a Custom Action, then double tap to activate when the textView is focused.
Right now it says "xxxxxx Option 1 [pause] link [pause] yyyy Option 2 [pause] link [pause]"
Once the textView is focused, if I swipe down on it it tells me the "Choose Option One" and "Choose Option Two". If after it says "Choose Option X" I double tap, the correction option is chosen.
Technically all is good, I just want to to announce the instructions to the user as it does in the video. Worst case scenario I will just append that to the accessibilityLabel
, but that's hacky.
I may be wrong but actions can't be read out as you mentioned, just adjustable values can.
I followed the content of this video thanks to this detailed summary and I heard :
"Actions available" is only read out with actions as you implemented, you cannot have anything else natively.
If I'm wrong, please let me know the timelapse of the WWDC video you heard what you mentioned, please ?
Now, if you need further information with the .adjustable
trait, including illustrations and code snippets (ObjC + Swift), I suggest you take a look at this site.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With