VoiceOver 辅助功能不适用于 OOB UITableView 滑动操作

VoiceOver accessibility not working with OOB UITableView swipe actions

我一直在努力研究如何使用 VoiceOver 访问 UITableView SwipeActions。

我想,因为它都是 Apple 开发的组件,所以它们都是 100% 可访问的,并且与 VoiceOver 完美配合。

为此,我创建了一个新的 iOS 项目,其中一个视图包含一个带有硬编码数据的 UITableView。

这是 ViewController 的代码:

class ViewController: UIViewController {
    @IBOutlet weak var tableView: UITableView!

    lazy var handler: UIContextualAction.Handler = {
        return { (action, _, _) in
            print("action \(action.title!) was clicked")
        }
    }()

    let data = [1,2,3,4,5,6,7]

    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

extension ViewController: UITableViewDelegate, UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return data.count
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! UITableViewCell

        cell.textLabel?.text = "title \(String(data[indexPath.row]))"

        return cell
    }

    func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
        print("Got trailingSwipeActionsConfigurationForRowAt for row \(indexPath.row)")

        return UISwipeActionsConfiguration(actions: getContextButtons("a title", "b title"))
    }

    func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
        print("Got leadingSwipeActionsConfigurationForRowAt for row \(indexPath.row)")

        return UISwipeActionsConfiguration(actions: getContextButtons("c title", "d title"))
    }

    func getContextButtons(_ titles: String...) -> [UIContextualAction] {
        return titles.map { UIContextualAction(style: .normal, title: [=10=], handler: handler) }
    }
}

table 在故事板中定义了所有默认设置,单元格具有 .Basic 样式和默认的 UITableViewCell class 绑定。

在 VoiceOver 模式下使用列表时,似乎没有任何效果:

  1. 成功滑动行后,由于某些无法解释的原因,焦点跳回到第一行,尽管滑动是在第 4 行完成的(图片:https://ibb.co/rm9PTPS

  2. 重新导航到第4行后(即滑动的行,图像:https://ibb.co/ZJk00h9), when navigating to the swipe action buttons themselves, it seems as if their frame isn't well defined, the screen scrolls too much to the right (in this case) beyond all the content, as demonstrated here: https://ibb.co/gyBFhJm

  3. 在滑动行的相邻行之间来回导航时,滑动操作按钮将完全无法访问。

我真的很感激任何对这个主题的帮助,来自那些肯定比我更了解它的人。 谢谢

正如 XLE_22 所指出的那样,在 VoiceOver 模式下滑动动作应作为 "Additional actions",根据他们的 link

我不知道如何将您的答案标记为正确答案,所以我投了赞成票,谢谢!