0

How to force voice over in Accessibility read my updated label

For example,

var label.text = 1

Then after 2 sec I update label to 2

label.text = 2

But the voice over not interact with 2

any suggest ?

mfaani
  • 33,269
  • 19
  • 164
  • 293
Joey
  • 601
  • 3
  • 10
  • 19

2 Answers2

3

If the question you're asking is, "How do I alert the user to a change in content," you can choose among three solutions.

  1. Post UIAccessibilityNotification(UIAccessibilityLayoutChangedNotification, label) to notify the system that the content has changed and force focus to the label.
  2. Post UIAccessibilityNotification(UIAccessibilityAnnouncementNotification, "Your announcement") to request that the system communicate the string to the user.
  3. Assign the UIAccessibilityTraitUpdatesFrequently trait to your label. The system will periodically announce changes to the content.
Justin
  • 20,509
  • 6
  • 47
  • 58
  • Hi can you please take a look at: https://stackoverflow.com/questions/60008538/why-isnt-uiaccessibilitynotification-not-moving-to-correct-argument – mfaani Feb 03 '20 at 16:26
2

Swift 5:

UIAccessibility.post(notification: .layoutChanged, argument: label)
WalterBeiter
  • 2,021
  • 3
  • 23
  • 48