MusiGenesis
MusiGenesis

Reputation: 75396

How to stop VoiceOver announcement for UISegmentedControl?

My app has a UISegmentedControl that contains two buttons. I'm able to access each button's accessibility fields; the problem I'm having is that for subviews of a segmented control, VoiceOver reads out the subview's accessibility properties and then announces the view's position within the segmented control, so the VoiceOver announcement for the first button is "Previous message. Button. One of two." and for the second button it's "Next message. Button. Two of two."

How can I prevent the last part of these announcements (the "one of two" and "two of two" parts), which have no real meaning to VoiceOver users?

Upvotes: 6

Views: 2946

Answers (1)

proxi
proxi

Reputation: 1263

You can set accessibilityTraits property of UISegmentedControl's subviews to UIAccessibilityTraitNone to disable "Tab X of Y" part of the VoiceOver:

    for (UIView *thisView in self.segmentedControl.subviews) {
        [thisView setAccessibilityTraits:UIAccessibilityTraitNone];
    }

Upvotes: 4

Related Questions