0

I am trying to reuse a custom UIKit control in a SwiftUI screen, so I have wrapped it in a UIViewRepresentable struct. However, it does not respond to accessibility tap gestures (double-tap while VoiceOver is enabled).

My code is like

struct SwiftUILargeButton: UIViewRepresentable {
  typealias UIViewType = LargeButton
  func makeUIView(context: Context) -> LargeButton {
    let button = LargeButton()
    ...
    return button
  }
}

struct ConfirmButtonContainer: View {
  var body: some View {
    SwiftUILargeButton()
  }
}

struct MyScreen: View {
  var body: some View {
    ZStack {
      ScrollView {
        ...
      }.overlay(
        ConfirmButtonContainer()
        .accessibilityAction {
          // Code to perform action
        }
      alignment: bottom)
    }
  }
}

It looks like VoiceOver selects the ConfirmButtonContainer View, and it reads it as "Confirm, button", but double-tapping the screen while it's selected only performs the accessibility action if there are no controls scrolled beneath the button in the Stack.

It looks like this may not be a UIViewRepresentable issue, but it also might be, so I'm leaving that in the description.

Greg
  • 10,360
  • 6
  • 44
  • 67

0 Answers0