Hi,
(using vc = view controller for brevity)
I have a UITableVC (UITableVC) embedded in a UINavigationController. In the UITableVC, I have a UISearchController initialized with UISearchController(searchResultsController: nil), which according to the docs means that the same vc as when search is inactive (i.e. the UITableVC) will also be used for presenting search results (both incrementally during entering search text and after hitting the “Search” button).
In code, this means that in my UITableVC subclass, I have in viewDidLoad:
searchController.dimsBackgroundDuringPresentation = false definesPresentationContext = true let searchBar = searchController.searchBar searchBar.delegate = self tableView.tableHeaderView = searchBar
However in such a setup, when searching is active (either during entering search string, or after confirming it with the “Search” keyboard button before canceling the search altogether through “Cancel” button), I cannot move with VoiceOver through the result cells. Accessibility Inspector in simulator also does not highlight any cell after I click on it. After canceling the search and going back to the original table vc, VoiceOver can again successfully visit all its cells, just as before initiating the search by activating the search field. Without VoiceOver, the cells are operable (it is possible to scroll through results and to select a cell with appropriate action triggered - pushing detail VC etc.)
With searchResultsController = non-nil vc, I get the behavior of original vc being displayed normally accessibly when search is not active, being displayed but not accessible when search is active but the entered search string is empty, and being not displayed and not accessible when search is active with search string being non-empty, instead the searchResultsController being displayed and accessible.
I suspect maybe the accessibility code for UISearchController when it is "active=true” somehow disables the original vc’s accessibility (e.g. through accessibilityElementsHidden = true) in order to make sure it does not interfere accessibility-wise with the presented results view controller, which however breaks if the original vc is specified to be the same as the resultsVC by using the UISearchController (searchResultsController: nil) initializer. Or some similar situation where the accessibility code simply does not take into account that UISearchController.searchResultsController can be nil.
Workaround is of course to use UISearchController with a non-nil searchResultsController, but that is quite a complication and extra work in both my code and storyboard, and still I think many developers will choose the nil searchResultsController in simple cases (and vast majority of them will not know that it presents an accessibility issue, which will result in their searching experience being inaccessible).
My main question now is: 1. is this a bug (I will report a rdar in such case)? or am I doing something wrong? 2. In case it is a bug: Is there a workaround other than using a separate non-nil searchResultsController (e.g. I tried setting accessibilityElementsHidden=false on the original vc’s view, but to no avail).
Thanks, Boris
— Boris Dušek A11Y LTD. |