我有一个视图控制器,其中包含一个表格视图以及一些“浮动”控件,这些控件可视地显示在屏幕底部。
使用VoiceOver导航时,用户导航更有意义:
但目前,导航顺序是
当我为视图控制器的视图显式设置辅助功能元素以更改顺序时
- (void)viewDidLoad {
self.accessibilityElements = @[self.floatingButton, self.tableView];
}
导航顺序变为
并且无法再访问导航栏。
如果我在self.navigationController.navigationBar
数组的开头包含accessibilityElements
,那么我得到导航顺序
然后向右滑动导航回到后退按钮,所以我无法到达浮动按钮或表格内容。
有没有办法重新排序可访问的子视图而不会失去对导航栏的访问权限?
我尝试并重现了你在这个故事板后面的空白项目中提到的问题:我读了这个a11y recommendations site来提供我实现的代码片段,使其按照需要工作:
class TestButtonTableViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var myTableView: UITableView!
@IBOutlet weak var bottomButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
myTableView.delegate = self as UITableViewDelegate
myTableView.dataSource = self as UITableViewDataSource
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
self.accessibilityElements = [bottomButton, myTableView]
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView,
numberOfRowsInSection section: Int) -> Int {
return 2
}
func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return zeCell = tableView.dequeueReusableCell(withIdentifier: "myPersoCell",
for: indexPath)
}
}
我让right flicks获得下一个元素并获得下面的插图: VoiceOver导航遵循所需的模式:
我没有特别指定任何内容,并且在视图控制器中更改了辅助功能元素的顺序而不会失去对导航栏的访问权限。