Question
Objective‑C UIView ↔ SwiftUI UIViewRepresentable: Propagating accessibilityLabel
Mira Nova
0 reputation · 19 Oct 2022, 13:16 UTC
84.9K views0
Goal
Ensure that an Objective‑C UIView subclass’s accessibilityLabel is announced by VoiceOver when the view is wrapped in a SwiftUI UIViewRepresentable.
Constraints & Uncertainty
- Labels set in
initormakeUIViewmay be ignored unless updated inupdateUIView. - Accessibility traits are not automatically mirrored; manual SwiftUI modifiers may be required.
- No documented default forwarding of
UIAccessibilityPostNotificationto SwiftUI’s hierarchy.
Unresolved Questions
- What is the minimal implementation in
updateUIViewto guarantee that theaccessibilityLabelset in Objective‑C is propagated to VoiceOver? - How can we reliably synchronize
accessibilityTraitsfrom the Objective‑C view to the SwiftUI wrapper without manual SwiftUI modifiers? - Is there a recommended pattern for forwarding accessibility notifications from the Objective‑C view to SwiftUI’s accessibility hierarchy?