uitableview - UISearchController 无法访问

标签 uitableview accessibility uisearchcontroller voiceover

我使用 UISearchController 和表格 View 实现了一个搜索屏幕。当我开始搜索某些内容时,搜索 Controller 会在 TableView 顶部添加一个 View (尽管它什么也不做),并且在我设置 searchController.active = false 之前, TableView 无法通过 VoiceOver 访问。我已经尝试了几乎所有看起来的方法,唯一的解决方案是放弃 UISearchController 而使用 UISearchBar。目前,一旦显示键盘并且搜索 Controller 处于事件状态,VoiceOver 选择器将从文本字段转到栏按钮项,然后跳过表格 View 并转到键盘。这是我的 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)

如何解决此问题并继续使用 UISearchController?目前,我的应用中的 VoiceOver 用户无法使用搜索功能。

最佳答案

这是因为底层 UITransitionViewaccessibilityViewIsModalSelector 设置了错误的值,这会在搜索 View 中捕获 VO,在您的情况下该值是空的。

我只能想到通过在私有(private) UITransitionView 上调配 accessibilityViewIsModal 来修补此行为。

我在我写的一篇博客文章中描述了该技术: http://www.morphineapps.com/blog/accessibility-on-ios

相关要点:

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

关于uitableview - UISearchController 无法访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33056324/

相关文章:

ios - 向上或向下滚动 UITableview 时更改值

ios - 在搜索 Controller 中更改状态栏背景

swift - 如何在我的搜索 Controller 中使用 queryStartingAtValue 来搜索用户?

accessibility - 表示辅助技术化学键的标记

accessibility - VoiceOver (Mac) 使用 tabindex 进行导航并忽略 aria- 属性

css - 在标记中重复主导航对可访问性不利吗?

iOS UISearchController TableView

swift - 无法从 didReceiveLocalNotification 重新加载 UITable

ios - 如何同时滚动多个tableview

ios - ImageView 没有回到合适的状态