如何使 UITableView 与大标题 VoiceOver 兼容?

人气:290 发布:2022-10-16 标签: ios accessibility uitableview uikit voiceover

问题描述

我的应用程序有一个表格视图,其中有一个大的空白 tableHeaderView 允许将可见单元格完全滚动到窗口之外(到底部).所以 {0,0} 的 contentOffset 意味着内容被滚动出窗口.初始 contentOffset 为 {0,{height of tableView}}.

My app has a table view with a large, blank tableHeaderView allowing to scroll the visible cells completely out of the window (to the bottom). So a contentOffset of {0,0} means, the content is scrolled out of the window. The initial contentOffset is {0,{height of tableView}}.

这一切都很好,但我在为其启用可访问性时遇到了一个难题.

This all works fine but I'm having a hard problem to enable accessibility for it.

用户逐步浏览元素,从导航栏及其栏按钮开始.只要她再次滑动以激活表格视图的第一个单元格,表格视图就会自动滚动到 {0,0}.但是,由于第一个单元格在此 contentOffset 处不可见,因此无法聚焦在它上,而是将焦点保持在最后一个选定的元素上.

The user steps through the elements, starting with the navigation bar and its bar buttons. As soon as she swipes again to activate the first cell of the table view, the table view automatically scrolls to {0,0}. However, since the first cell isn't visible at this contentOffset, it fails to focus on it and keeps the focus on the last selected element.

我可以以某种方式阻止这种情况或手动控制 VO 模式下的 contentOffset 吗?

Can I somehow prevent this or control the contentOffset in VO mode manually?

我创建了一个演示项目来显示我的问题.

I created a demo project showing my problem.

推荐答案

如果空标题中没有可访问的内容,请考虑在加载时以编程方式设置内容偏移量,以防 UIAccessibilityIsVoiceOverRunning().您还需要监控 UIAccessibilityVoiceOverStatusChanged 并执行相同操作.

If there is no accessible content in the empty header, consider setting the content offset programmatically upon load in the event that UIAccessibilityIsVoiceOverRunning(). You will also want to monitor for UIAccessibilityVoiceOverStatusChanged and do the same.

603