gpt4 book ai didi

ios - 如何在不失去对导航栏的访问权限的情况下更改 View Controller 中可访问性元素的顺序?

转载 作者:行者123 更新时间:2023-11-29 11:28:53 24 4
gpt4 key购买 nike

我有一个 View Controller ,其中包含一个 TableView 以及一些显示在屏幕底部的“ float ”控件。

当使用 VoiceOver 导航时,用户像这样导航会更有意义:

  • 后退按钮(导航栏)
  • 标题(导航栏)
  • 编辑按钮(导航栏)
  • float 按钮
  • 表格内容

但是目前,导航顺序是

  • 后退按钮(导航栏)
  • 标题(导航栏)
  • 编辑按钮(导航栏)
  • 表格内容
  • float 按钮

当我为我的 View Controller 的 View 显式设置可访问性元素以更改顺序时

- (void)viewDidLoad {
self.accessibilityElements = @[self.floatingButton, self.tableView];
}

导航顺序变为

  • float 按钮
  • 表格内容

并且导航栏不再可访问。

如果我在 accessibilityElements 数组的开头包含 self.navigationController.navigationBar,那么我会得到导航顺序

  • 后退按钮(导航栏)
  • 标题(导航栏)
  • 编辑按钮(导航栏)

再次向右滑动会导航回后退按钮,所以我无法到达 float 按钮或表格内容。

有没有办法在不失去对导航栏的访问权限的情况下重新排序可访问的 subview ?

最佳答案

我尝试并重现了您在这个 Storyboard之后的空白项目中提到的问题: enter image description here我读了这个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获取下一个元素并获得以下插图: enter image description here enter image description hereVoiceOver 导航遵循所需的模式:

  1. 后退按钮(导航栏)
  2. 标题(导航栏)
  3. 编辑按钮(导航栏)
  4. float 按钮。
  5. 表格内容。

我没有特别指定任何内容,并且更改了 View Controller 中辅助功能元素的顺序,同时又不失去对导航栏的访问权限

关于ios - 如何在不失去对导航栏的访问权限的情况下更改 View Controller 中可访问性元素的顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55658803/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com