Search code examples
uibuttonuisegmentedcontroltvosapple-tv

tvOS navigating through ui elements


I am developing for tvOS at the moment and I have added a UISegmentedControl, this gets focused automatically by the tvOS focus engine. When I added a UIButton, this became the first focused item.

How I do go about setting the first focused item and being able to navigate between them?


Solution

  • Add a read only preferredFocusedView property to your view controller that returns the view you would like to start focused:

    override weak var preferredFocusedView: UIView? {
        get {
            return segmentedControl
        }
    }