I have a horizontal stackview with a button and label horizontally
When I turn on voice over, text in these buttons are not reading at all. All others works fine.
Below is how i setup my code. Please guide how to enable these. Not sure why this isn't working
I have my button text and label text taking dynamic values
Also if any info why the accessibilityIdentifier is used would really help. I couldn't find clear explanation for this
self.myHorizontalStackView.isAccessibilityElement = true
//Accessibility for Button
self.submitButton.isAccessibilityElement = true
self.submitButton.accessibilityTraits = UIAccessibilityTraitStaticText
self.submitButton.accessibilityLabel = screenControls.buttonTitle
//Accessibility for Label
self.addressLabel.isAccessibilityElement = true
self.addressLabel.accessibilityTraits = UIAccessibilityTraitStaticText
self.addressLabel.accessibilityLabel = screenControls.address1
So the problem looks like it's coming from your stackView itself. See this other SO question/answer on the subject:
If a container view is accessible, its child views are often obscured to avoid confusion about what the user is trying to interact with.
So here, change your first line in the snippet you shared to:
self.myHorizontalStackView.isAccessibilityElement = false
and that should enable VoiceOver to find the subviews of the stackView.
As far as your other question:
Also if any info why the accessibilityIdentifier is used would really help. I couldn't find clear explanation for this
If you are asking what the identifier would be used for, it's primarily for testing purposes. By setting unique identifiers to your views, your tests can easily use the accessibility engine to find specific views and perform any actions you'd want to test. In terms of VoiceOver, the accessibilityIdentifier does not have a role.
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