Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make VoiceOver say "Swipe Up or Down to Select a Custom Action, then double tap to activate"

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.

like image 827
regina_fallangi Avatar asked Mar 01 '19 13:03

regina_fallangi


2 Answers

  • When accessibilityCustomActions is set, OS announce "Actions Available. Swipe Up or Down to Select a Custom Action, then double tap to activate"
  • You can set the accessibilityHint to provide a custom message.
like image 52
Mazen Kasser Avatar answered Nov 04 '22 04:11

Mazen Kasser


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 :

  • "Adjustable, swipe up or down with one finger to adjust the value" for the adjustable element : video.
  • "Actions available" only when the element with custom actions is selected : video.

"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.

like image 1
XLE_22 Avatar answered Nov 04 '22 02:11

XLE_22