2

I've got a view controller that contains a table view along with a few "floating" controls that appear visually at the bottom of the screen.

When navigating with VoiceOver, it would make more sense for the user to navigate like:

  • back button (navigation bar)
  • title (navigation bar)
  • edit button (navigation bar)
  • floating button
  • table contents

But currently, the navigation order is

  • back button (navigation bar)
  • title (navigation bar)
  • edit button (navigation bar)
  • table contents
  • floating button

When I explicitly set the accessibility elements for my view controller's view to change the order like

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

the navigation order becomes

  • floating button
  • table contents

and the navigation bar is no longer accessible.

If I include self.navigationController.navigationBar at the beginning of the accessibilityElements array, then I get the navigation order

  • back button (navigation bar)
  • title (navigation bar)
  • edit button (navigation bar)

and swiping right again navigates back to the back button, so I can't reach the floating button or table contents.

Is there a way to reorder the accessible subviews without also losing access to the navigation bar?

Greg
  • 10,360
  • 6
  • 44
  • 67

1 Answers1

1

I tried and reproduce the problem you mentioned in a blank project following this storyboard : enter image description here I read this a11y recommendations site to provide this code snippet I implemented to make it work as desired :

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)
    }
}

I made right flicks to get the next elements and obtained the illustrations hereunder : enter image description here enter image description here The VoiceOver navigation follows the desired pattern :

  1. Back button (navigation bar).
  2. Title (navigation bar).
  3. Edit button (navigation bar).
  4. Floating button.
  5. Table contents.

I specified nothing in particular and changed the order of accessibility elements in a view controller without losing access to the navigation bar.

XLE_22
  • 5,124
  • 3
  • 21
  • 72
  • Huh. This app has a complicated custom navigation controller system that may be interfering with that behavior. Thanks for verifying the behavior in a simpler app. It looks like navigation works almost correctly when I follow that pattern. The focus starts on my floating button, and I can't initially flick left to select the navigation bar, but if I flick right to select the table, then flick left a couple of times it does select the navigation bar. Investigating whether I can use `UIAccessibilityPostNotification` to select the navigation bar initially. – Greg Apr 15 '19 at 16:31
  • 1
    @Greg : if you notice interferences with your current navigation bar, you could hide it for VoiceOver and create accessibility elements to be added in an array of accessibility elements so as to order the whole page as desired for instance... not an easy way but that could help if need be. – XLE_22 Apr 15 '19 at 17:48
  • I have not found a good solution. I'm hoping that we will be able to remove the custom navigation controller system in the future and that will fix this issue. – Greg Jun 18 '19 at 15:10