Reputation: 43
I am currently working on an app and I am using UIAccessibility to make it intuitive and easy to use for everyone.
I am facing what I think is a simple challenge but I just can't figure it out and I'm in need of any guidance and/or assistance.
I have a tableView and when a cell is tapped depending on its content it either presents an alert view or a viewController. When voice over is enabled and a cell is tapped the voice over is stuck at the previous view and not on the presented viewController or alertView. How do I make it so when a cell is tapped voice over focuses on the present view and not on the previous one.
I have tried setting accessibilityViewIsModal for the previous view to false and true for the presented view.
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView. accessibilityViewIsModal = false
}
Actual result: voice over focuses on the previous view Expected result: Voice over should focus on the presented alert view.
Upvotes: 0
Views: 2627
Reputation: 335
Most of times when presenting an alert, or a modal view controller, it should just work. Can you share more details on how are you presenting those? If you are using custom modal presentations or you have a custom alert view, you may sometimes need to notify UIAccessibility that the screen changed. You can do it posting a notification like this:
UIAccessibility.post(notification: .screenChanged, argument: customModalView)
Where customModalView is the view you want to get VoiceOver's focus. Sometimes you may also find the problem you described where the focus can still jump to elements in the view underneath the presented one. For that you can use the property you mentioned accessibilityViewIsModal
. But the value of this property is false by default, you have to set your 'modalView' to be modal for accessibility purposes when presented and that will allow VoiceOver to know that it needs to skip any sibling views.
customModalView.accessibilityViewIsModal = true
I hope this helps!
Upvotes: 3