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:
But currently, the navigation order is
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
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
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?
I tried and reproduce the problem you mentioned in a blank project following this storyboard : 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 :
The VoiceOver navigation follows the desired pattern :
I specified nothing in particular and changed the order of accessibility elements in a view controller without losing access to the navigation bar .
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.