I’m hoping someone here has experience creating accessible apps. I’m attempting to update Voiceover users that something in my UI has changed, without redirecting the focus of Voiceover. From what I can tell, this is done using the UIAccesibility, which you can read about here:
https://developer.apple.com/documentation/objectivec/nsobject/uiaccessibility
Unfortunately, this documentation isn’t clear on how one would implement the functions associated with this type to accomplish what I’m trying to do, and there don’t seem to be examples/tutorials anywhere online, but the closest thing I’ve found and attempted to replicate is what I found here:
https://developer.apple.com/documentation/objectivec/nsobject/uiaccessibility
This is a simplified version of what I’m doing, but I have two different views for information in a quiz game I’m making. These two views will be conditionally shown in a parent view (ParentView), based on whether or not the question has been answered.
UnansweredQuestionView is to be shown in ParentView when the question hasn’t been answered, and AnsweredQuestionView is shown when the question has been answered.
In my game, there are multiple questions presented on-screen at once, with a field at the bottom for the player to guess the answer. I want my visually-impaired players to be informed when they answer something correctly, without having to redirect Voiceover’s focus through each question to see which one has been solved. That’s why I’m trying to use a UIAccessibilityNotification. is why I
Here’s the simplified code:
Struct UnansweredQuestionView: View {
Let question: String
Var body: some View {
Text(question)
}//body
}//struct
Struct AnsweredQuestionView: View {
Let answer: String
Var body: some View {
Text(answer)
}//body
}//struct
Struct ParentView: View {
/*key in these dictionaries is the question, value is the answer*/
Var questionData = [[String: String]]()
Var currentAnswer = “”//Represents the user’s input
//some initializer that fills questionData variable
Var body: some View {
ForEach(questionData, id: \.self.value) { data in
If answer != data.value {
UnansweredQuestionView(question: data.key)
} else {
AnsweredQuestionView(data.value)
.onAppear() {
UIAccessibility.post(notification: .announcement, argument: "Solved")
}//onAppear
}//conditional
}//ForEach
}//body
}//struct
}//body
Why would this not be announcing anything to Voiceover when the view changes?
}//struct
While this code is valid, Voiceover doesn’t announce anything when the view changes.