Kedar
Kedar

Reputation: 1298

ios voiceover for UITableView sections

Is there some way that I can avoid the section titles of the UITableView from saying "heading" in the voiceover mode after the text on the section is read? I am providing custom views in viewForHeaderInSection: . I have tried setting isAccessibilityElement to NO and accessibilityTraits to UIAccessibilityTraitNone for the custom view that I return in viewForHeaderInSection. But I cannot suppress the callout "heading" in voiceover mode. For e.g. if I set the label in the section as "Dates", it will be read out as Dates "pause" heading.

The reason I need to do this is that some of the sections are just custom messages with 0 rows, they are not really headings of any kind. I do not want to have them as rows within a section.

Upvotes: 4

Views: 2242

Answers (2)

0x0
0x0

Reputation: 21

You can implement accessibilityElementDidBecomeFocused method in your custom view,when this view did become focused and post UIAccessibilityLayoutChangedNotification to VoiceOver and focus to itself, and then return the traits UIAccessibilityTraitNone

- (void)accessibilityElementDidBecomeFocused {
       UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification,   self);
}

- (UIAccessibilityTraits)accessibilityTraits {
    return UIAccessibilityTraitNone;
}

Upvotes: 0

Kedar
Kedar

Reputation: 1298

Answering my question to document the solution that I went with. Used a custom view that implements UIAccessibilityContainer and returned that in viewForHeaderInSection. Implemented the three methods in the protocol to only mark the label in the view as an accessibility element. This is the only way I could get the section to not append "heading" at the end of the label voiceover readout.

Upvotes: 0

Related Questions