'(iOS voice over) how to make both containerView and childView focusable when voice over is on

I'm working on supporting accessibility on my app.

I have cardViews that contains information and button per card.

I want to make these card focusable in order of

[card1 -> card1 button -> card2 -> card2 button]

so I made for example this code

class CardView: UIView {
  let actionButton = UIButton()

  func prepareAccessibility() {
    isAccessibilityElement = true
    accessibilityLabel = "~~~"
    actionButton.isAccessibilityElement = true
    actionButton.accessibilityLabel = "~~~"
    accessibilityElements = [self, actionButton].map { $0 as Any }
  }
}

but when I test it, focus only goes to container view (cardView) and not goes to actionButton.

what am I missing??



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source