代码之家  ›  专栏  ›  技术社区  ›  Greg

如何更改视图控制器中辅助功能元素的顺序而不丢失对导航栏的访问权限?

  •  0
  • Greg  · 技术社区  · 7 年前

    使用VoiceOver导航时,用户可以像这样导航:

    • 后退按钮(导航栏)
    • 标题(导航栏)
    • 浮动按钮
    • 表目录

    • 后退按钮(导航栏)
    • 标题(导航栏)
    • 表目录
    • 浮动按钮

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

    导航顺序变为

    • 表目录

    导航栏也不再可用。

    如果我包括 self.navigationController.navigationBar 一开始 accessibilityElements 数组,然后我得到导航命令

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

    再次向右滑动将导航回“后退”按钮,因此我无法触及浮动按钮或表格内容。

    0 回复  |  直到 7 年前
        1
  •  1
  •   XLE_22    7 年前

    我试着把你在一个空白项目中提到的问题复制到这个故事板上: 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 here 画外音导航遵循所需的模式:

    1. (导航栏) .
    2. 职务 .
    3. 编辑按钮 .
    4. 浮动按钮。
    5. 表格内容。

    我没有特别说明 更改了视图控制器中辅助功能元素的顺序,而不会丢失对导航栏的访问权限