serdar aylanc
serdar aylanc

Reputation: 1347

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.

Upvotes: 2

Views: 2037

Answers (1)

XLE_22
XLE_22

Reputation: 5671

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.

Upvotes: 1

Related Questions