VoiceOver should read the accessibilityLabel
property of any accessibility element on the screen. I have a UIImageView
called mediaImageView
, the code below sets up accessibility on this view and is called in awakeFromNib
in a UITableViewCell
subclass.
Rather than reading image
, VoiceOver reads articleMediaCell_image
which is the accessibilityIdentifier
. Can anyone explain why this this could be happening?
(testing on device with iOS 13.3, issue happens whether or not custom actions are set)
mediaImageView.isAccessibilityElement = true
mediaImageView.accessibilityIdentifier = "articleMediaCell_image"
mediaImageView.accessibilityLabel = "image"
mediaImageView.accessibilityCustomActions = [
UIAccessibilityCustomAction(
name: "expand to fullscreen",
target: self,
selector: #selector(imageTapped)
)
]
An identifier can be used to uniquely identify an element in the scripts you write using the UI Automation interfaces. Using an identifier allows you to avoid inappropriately setting or accessing an element's accessibility label. Current page is accessibilityIdentifier. Apple.
accessibilityLabel When a view is marked as accessible, it is a good practice to set an accessibilityLabel on the view, so that people who use VoiceOver know what element they have selected. VoiceOver will read this string when a user selects the associated element.
By using your app with VoiceOver on, you can establish a baseline of its accessibility. To start auditing, choose Settings > Accessibility > VoiceOver, and enable VoiceOver. Then, open your app and use the specified action whenever you want to test VoiceOver.
TalkBack is the Google screen reader included on Android devices. TalkBack gives you spoken feedback so that you can use your device without looking at the screen. You can drag one finger around the screen and TalkBack announces the icons, buttons, and other items as you drag your finger over them.
In this iOS accessibility tutorial, you’ll transform an existing app to make it more accessible for people with visual disabilities. In the process, you’ll learn how to: Use VoiceOver. Check your app with the Accessibility Inspector.
As you scroll through the different accessibility elements, VoiceOver reads a full description of each cell, including the difficulty level. Every time you expose a new accessibility element, as you did here with the difficulty level, you should run the audit again.
In this iOS accessibility tutorial, you’ll transform an existing app to make it more accessible for people with visual disabilities. In the process, you’ll learn how to: Use VoiceOver. Check your app with the Accessibility Inspector. Implement accessibility elements with UIKit. Build a better user experience for people with disabilities.
First, open it in the Xcode menu by navigating to Xcode ▸ Open Developer Tool ▸ Accessibility Inspector. The target chooser lets you pick which device you’d like to inspect. This could be your MacBook Pro, an iOS device or your simulator. Live previews of accessibility elements let you test right in the simulator.
This happens due to the fact that you have set the trait (image) of the control type as the value for accessibilityLabel
here:
mediaImageView.accessibilityLabel = "image"
/*
This won't work, because iOS already knows that this is an image from the element's traits.
Due to this, the redundant value is ignored and the voiceover falls back to reading the `accessibilityIdentifier`.
*/
Use any value - "media" for example - that is other than the trait of the object, because the voiceover will read the accessibility label value followed by the trait of the control type like so: "Media Image".
mediaImageView.accessibilityLabel = "media" /* This will work */
Excerpt from accessibilityLabel
Apple Documentation:
Note that the label never includes the control type (such as button) because the traits of the accessibility element contain that information.
Set the accessibilityTraits
of your mediaImageView
to UIAccessibilityTraits.button
.
mediaImageView.accessibilityTraits = UIAccessibilityTraits.button
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With