简体   繁体   中英

Correct implementation of VoiceOver accessibility in iOS with `accessibilityLabel` and `accessibilityHint`

I'm trying to optimize my app. What is the best practice method for implementing accessibility in iOS with accessibilityLabel and accessibilityHint ? Are accessibility labels always required?

My app is very dynamic and objects in the view get updated frequently depending on the user's action. For example, a view might start off as one shape and later turn into another shape. Accordingly, the accessibilityLabel and accessibilityHint of each object is updated frequently to reflect the changed view for users with VoiceOver turned on.


Questions

  1. Is it safe to expect that when VoiceOver is not running (ie !UIAccessibilityIsVoiceOverRunning() ) then setting accessibilityLabel and accessibilityHint is completely unnecessary?

  2. Are there assistive technologies other than VoiceOver that a user might use that access accessibilityLabel and accessibilityHint ?

What is the best practice method for implementing accessibility in iOS with accessibilityLabel and accessibilityHint?

You should consider, rather than "setting" the accessibility label, overriding the property implementation. Allow the view that requires an accessibility label to calculate its value when required, rather than keeping the value in sync constantly. Much easier! You would do so with code that looks like this.

override public var accessibilityLabel: String? {
    get {
        return "Calculated label"
    }
    set {
       //Specifically do nothing. We're not "setting a property" we're responding to changes of the internal views.
    }
}

Are accessibility labels always required?

Yes and no. Accessibility labels are always required for elements that present information and are individually focusable (you may have a group f controls, wrapped in one layout, with one accessibility label). I can say with reasonably certainty that in the context of your question, removing the accessibility label is absolutely the incorrect thing to do.

Is it safe to expect that when VoiceOver is not running (ie !UIAccessibilityIsVoiceOverRunning()) then setting accessibilityLabel and accessibilityHint is completely unnecessary?

No, there are other uses for accessibility properties outside of VoiceOver.

Are there assistive technologies other than VoiceOver that a user might use that access accessibilityLabel and accessibilityHint?

There are certainly assistive technologies outside of VoiceOver, and they are dependent on aa myriad of accessibility properties. (braille boards, switch access, etc)

Conclusion

It seems to me like you are trying to get around accessibility as a software practice and rationalize doing so. This is the wrong thought process. HOWEVER, it may indeed be impractical to make the view that you have accessible because of some fundamental design problem. You should consider whether or not the thing you have is designed in a way that it can be made accessible from a development/API point of view. The APIs do limit you from accomplishing certain things. Whether or not your up against one of these limitations is NOT a question you can ask on StackOverflow and the solution is NOT to omit accessibility information. It is to redesign the control OR perhaps to provide an alternate accessible implementation... though this route should be considered VERY carefully. In general separate is not equal.

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