Search code examples
uitableviewaccessibilityuisearchcontrollervoiceover

UISearchController in-accessible


I have implemented a search screen using UISearchController and a table view. When I start searching for something, the search controller adds a view on top of the table view (although, it does nothing) and until I set the searchController.active = false, the table view is in-accessible with VoiceOver. I have tried almost everything it seems, and the only solution is to abandon UISearchController for UISearchBar. Currently, once the keyboard is shown and the search controller is active, the VoiceOver selector will go from the text field, to a bar button item, then it skips the table view and goes to the keyboard. Here is my setup of UISearchController.

searchController = UISearchController(searchResultsController: nil)
    searchController.searchResultsUpdater = self
    searchController.delegate = self
    searchController.hidesNavigationBarDuringPresentation = false
    searchController.dimsBackgroundDuringPresentation = false
    searchController.searchBar.searchBarStyle = .Minimal
    searchController.searchBar.keyboardAppearance = .Dark
    searchController.searchBar.showsCancelButton = false
    searchController.searchBar.delegate = self
    searchController.searchBar.text = prefilledSearch
    searchController.view.layer.borderColor = UIColor.redColor().CGColor
    searchController.view.layer.borderWidth = 1.0
    searchController.view.isAccessibilityElement = false
    searchController.view.hidden = true
    searchController.searchBar.setShowsCancelButton(false, animated: false)

How can I get this fixed and continue to use UISearchController? currently, search is not usable with VoiceOver users in my app.


Solution

  • That's because underlying UITransitionView sets incorrect value for accessibilityViewIsModalSelector which traps VO within search view, which in your case is empty.

    I can only think of patching this behavior by swizzling accessibilityViewIsModal on private UITransitionView.

    I described the technique in a blog post I wrote: http://www.morphineapps.com/blog/accessibility-on-ios

    Relevant gists:

    https://gist.github.com/pronebird/0d3c06485de50e100d1e93bcde08c94c#file-snippet-m https://gist.github.com/pronebird/66aa70b005ed9af8d357cdc7e940542b#file-search-controller-snippet-m