'Is it possible for UIStackView to get focus in tvOS?

I have two UILabels in a UIStackView. Is it possible for the UIStackView to get focus and gestures in tvOS?



Solution 1:[1]

Items in a stack view can receive focus, but not the stack view itself. By default, labels cannot receive focus either. Buttons are the most commonly items that receive focus.

Solution 2:[2]

You can make a stack view focusable by subclassing the stackview, overriding canBecomeFocused and using that subclass:

class FocusableStackView: UIStackView {
    override var canBecomeFocused: Bool {
        return true
    }
}

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 picciano
Solution 2 Anthony Olds