13

I'd like to have my QR code scanning app inform the user when it finds a QR code. For sighted users, this works using a label at the bottom that updates to notify the user. However, a blind user would have to tap on that label again to have it read by Voice Over. I would much prefer it to just read automatically.

The closest I can find to this question is UIAccessibility - Read all the labels and buttons on the screen from top to down, which wasn't possible. While this doesn't bode well for my app, that was a year ago. Has Apple updated it's UIAccessibility protocol in any way to allow this?

As a last resort I suppose I could play my own mp3 recording if VoiceOver is on.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Connor Hargus
  • 317
  • 2
  • 11
  • 1
    Have you tried https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAccessibility_Protocol/#//apple_ref/c/data/UIAccessibilityAnnouncementNotification – Wain Aug 02 '15 at 22:05

2 Answers2

24

You can make VoiceOver speak any string any time you want by calling:

UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, NSLocalizedString("QR code has been detected", comment: ""))

Swift 4

UIAccessibility.post(notification: .announcement, argument: "Text")

There is no direct way to tell VoiceOver to speak updates of an element that VoiceOver cursor is not on. This (i.e. speaking the same content "manually") is a feasible workaround.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Boris Dušek
  • 1,272
  • 11
  • 12
5

You can move VoiceOver focus to an element by using the following:

UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, elementToFocusOn) 

VoiceOver will then parse and read the accessibility properties associated with that element.

TylerH
  • 20,799
  • 66
  • 75
  • 101
xoogler
  • 211
  • 5
  • 12