Struggling with Implementing VoiceOver for Custom UI Elements in iOS 17
Hey everyone, I'm running into an issue that's driving me crazy. I've been banging my head against this for hours... I'm stuck on something that should probably be simple... Currently developing an iOS application with a strong focus on accessibility features. I need to ensure that all interactive elements are properly recognized by VoiceOver, especially a custom UIView that contains multiple subviews. I’ve added accessibility labels for the primary view, but VoiceOver does not seem to read them correctly. Here’s the relevant code snippet: ```swift class CustomView: UIView { let titleLabel = UILabel() let actionButton = UIButton() override init(frame: CGRect) { super.init(frame: frame) setupView() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } private func setupView() { titleLabel.text = "Important Title" actionButton.setTitle("Tap me", for: .normal) addSubview(titleLabel) addSubview(actionButton) // Accessibility settings isAccessibilityElement = false titleLabel.accessibilityLabel = "Important Title" actionButton.accessibilityLabel = "Tap me" } } ``` To troubleshoot, I’ve tried setting `isAccessibilityElement` to `true` for both the label and the button, but this approach didn’t yield any better results. The VoiceOver does read the labels, but it’s not transitioning smoothly between elements. At one point, I also experimented with grouping these views into a single accessible element by wrapping them in a stack view, but the VoiceOver still skips over them. I’m not sure if I need to implement a custom accessibility container or if there’s a simpler solution. Could anyone provide insights on best practices for making custom UI components accessible in iOS 17? Any tips on debugging accessibility issues with VoiceOver would be greatly appreciated. Has anyone else encountered this? For context: I'm using Swift on Windows. Any ideas what could be causing this?