iostvosapple-tvtvos9.1tvos10

How to move focus at button in collectionview cell in tvos application?


I am working on apple TV application. In my app, I have made a screen which has a collection view. In that case, I am able to move focus at collection view cell but not able to move focus to the button which is in collection view cell so can anyone help me to solve this issue ?

please give me an answer if anyone knows this answer.


Solution

  • I am able to solve this problem by adding below methods in collectionViewCell subclass.

    In CollectionViewCell Subclass

    override var preferredFocusEnvironments: [UIFocusEnvironment]{
        // Condition
    }
    override func shouldUpdateFocus(in context: UIFocusUpdateContext) -> Bool {
        // Condition
    }
    override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
        // Condition
    }
    

    you can see more at this link: enter link description here.