简体   繁体   中英

Swift - TableViewCell Accessibility (VoiceOver)

Hierarchy in my TableViewCell in storyboard is like below:

When I activated voiceover, it reads the labels not in the order in the storyboard but in a mixed order.

->TableViewCell
--->Label1
--->Label2
--->Label3
--->Button
--->Label4

Is there a way to change the voiceover hierarchy for tableviewcell?

Edit: I tried this in cellforrowat , but nothing changed.

cell.accessibilityElements = [Label1, Label2, Label3, Button, Label4]

Edit 2: Setting isAccessibilityElement = false makes my accessibilityElements order work. But cell selection to voiceover is not working now.

You cannot have simultaneously a parent view (your table view cell) and its child views (label1, button...) that are both accessible with VoiceOver: either your cell can be selected or its content.

Instead of selecting each element inside your cell, vocalize the labels when your cell is selected and add custom actions if buttons are available inside.

That's the best way to improve the user experience for your table view cell: one unique selection with possible actions.

This answer may help for your implementation.

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