Joey
Joey

Reputation: 621

Accessibility: Voice over read update label?

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 ?

Upvotes: 0

Views: 3376

Answers (2)

WalterBeiter
WalterBeiter

Reputation: 2354

Swift 5:

UIAccessibility.post(notification: .layoutChanged, argument: label)

Upvotes: 2

Justin
Justin

Reputation: 20609

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.

Upvotes: 3

Related Questions