简体   繁体   中英

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?

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];
    }

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