I’ve a easy app to announce a textual content when tapping a button. Right here is the code (it is in SwiftUI however the identical conduct arises utilizing UIKit)
struct ContentView: View {
var physique: some View {
VStack(spacing: 20) {
Textual content("Take a look at accessibility")
.font(.largeTitle)
Spacer()
Button {
let attributedMessage: NSAttributedString = NSAttributedString(
string: "Take a look at accessibility announcement",
attributes: [
.accessibilitySpeechQueueAnnouncement: true
]
)
UIAccessibility.put up(notification: .announcement, argument: attributedMessage)
} label: {
Textual content("Take a look at accessibility button")
}
Spacer()
}
}
}
There are two behaviors:
- If the accessibility focus is moved to the button and the accessibility information is absolutely learn and I do double faucet to carry out the button motion, the announcement is not learn
- If the accessibility focus is moved to the button and whereas accessibility is being learn (however not fully) I do double faucet to carry out the button motion, the announcement is learn
Right here you’ll be able to see it (first ready VoiceOver to learn the complete accessibility information after which double tapping whereas accessibility information is being learn).
Why the announcement isn’t learn within the first case?
Setting accessibilitySpeechQueueAnnouncement to false as a substitute of true provokes the announcement not being learn in any case.