I want to make a textfield and a subview on the text field accessible by VoiceOver. If I use UIAccessibilityContainer
methods, I can only make the subviews accessible. Is there some way to do this?
iOS Accessibility: make UITextField and specified subview accessible
Asked Answered
Did you find the way? It seems like Apple's voicemail implementation works that way. I also am looking for a way to do so. –
Alginate
I did not. There seems to be no way without major refactoring (and decreasing code and design quality). –
Initiatory
Actually i'm on the blink of making it to work. Try this, create a new view subclass and add it as a subview of whatever the parent view is. The role of this subview is only to contain a container and 1 element of the same size as the view. So when the VoiceOver try to access it, it will hit that element first then the rest of the subviews' accessible controls. I can show code if you are still trying it. –
Alginate
This is actually a complicated view hierarchy, so adding the subview to a new container subview complicates things significantly. –
Initiatory
Yes if you have a bunch of containers. For what I am going for is 1 container and 1 element. Other subviews can remain as accessible as before. –
Alginate
No. You must go up one level in the accessibility hierarchy. Implement the container protocol on your view's superview and return all of its descendants as children (and, thus, siblings of each other).
try this,
textfield.isAccessibilityElement = YES;
textfield.accessibilityElementsHidden = NO;
Leave the container methods for time being.
© 2022 - 2024 — McMap. All rights reserved.