In my app, I have an UITableView with asynchronous data loading : when the view controller is loaded I show a modal activity spinner and start the HTTP request. When it is completed I hide the spinner and execute reloadData() on my table view. I also return response?.count ?? 0 as a number of rows to make sure that the list it initially empty when the data is not ready yet.
It works like a charm, but I have an issue with VoiceOver : when opening the view controller, VoiceOver goes into the table and says "empty list". When the data is loaded it goes to the last element of the table.
This behavior is not very optimal : I would like VoiceOver to not focus the table while it's empty (it doesn't need to focus the modal spinner since we already have a sound while loading) and then go to the first element when it's loaded.
How may I do that ?
You want to set up your loading overlay screen as a modal view. Modal means that the things behind the view are not actionable (or focusable by VoiceOver).
//Instantiate a view controller with your loading spinner.
_modalDialogViewController = [[UIStoryboard storyboardWithName:@"ModalDialog" bundle:[NSBundle mainBundle]]
instantiateViewControllerWithIdentifier:@"AccessibleSpinnerModal"];
//Make this view controller modal, meaning only things on this screen will be actionable/focusable.
_modalDialogViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
You may also then need to use accessibility notifications in either of these styles.
//Announce that content is loading directly
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, "Stuff is laoding");
Or
//Shift focus to the view in your modal that is sharing the status of the loading content.
UIAccessibilityPostNotification(UIAccessibilityLayoutChanged, spinnerView);
This will cause focus to move to that view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With