简体   繁体   中英

VoiceOver accessibility not working with OOB UITableView swipe actions

I've been struggling with how to make UITableView SwipeActions accessible using VoiceOver.

I'd assume, since it's all Apple developed components, it'll all be 100% accessible and work perfectly with VoiceOver.

For this purpose I've created a new iOS project, with a single view containing a single UITableView with hard-coded data.

This is the ViewController's code:

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: $0, handler: handler) }
    }
}

The table is defined in the storyboard with all the default settings, the cell has the .Basic Style and the default UITableViewCell class binding.

When using the list in VoiceOver mode, nothing seems to work as expected:

  1. Upon successfully swiping the row, for some unexplained reason the focus jumps back to the first row, despite the swipe being done on the 4th row (image: https://ibb.co/rm9PTPS )

  2. After re-navigating to the 4th row (ie the swiped row, image: 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. When navigating back and forth between the adjacent rows to the swiped row, the swipe action buttons become inaccessible altogether.

I'd really appreciate any help on the subject, from people who surely know much more about it than I do. Thanks.

As XLE_22 kindly pointed out, swipe actions should be served as "Additional actions" in VoiceOver mode, as per their link .

I don't know hoe to mark you answer as the correct one, so I upvoted it, thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM