rai212
rai212

Reputation: 781

UIAccessibility post announcement not always read if fired by button

I have a simple app to announce a text when tapping a button. Here is the code (it's in SwiftUI but the same behavior arises using UIKit)

struct ContentView: View {
    var body: some View {
        VStack(spacing: 20) {
            Text("Test accessibility")
                .font(.largeTitle)
            Spacer()
            Button {
                let attributedMessage: NSAttributedString = NSAttributedString(
                    string: "Test accessibility announcement",
                    attributes: [
                        .accessibilitySpeechQueueAnnouncement: true
                    ]
                )

                UIAccessibility.post(notification: .announcement, argument: attributedMessage)
            } label: {
                Text("Test accessibility button")
            }
            Spacer()
        }
    }
}

There are two behaviors:

  1. If the accessibility focus is moved to the button and the accessibility info is fully read and I do double tap to perform the button action, the announcement is not read
  2. If the accessibility focus is moved to the button and while accessibility is being read (but not completely) I do double tap to perform the button action, the announcement is read

Here you can see it (first waiting VoiceOver to read the full accessibility info and then double tapping while accessibility info is being read).

Why the announcement is not read in the first case?

Setting accessibilitySpeechQueueAnnouncement to false instead of true provokes the announcement not being read in any case.

Upvotes: 2

Views: 311

Answers (0)

Related Questions