I have implemented programmatically this:
- List of tableView cells.
- Each tableViewCell contains a collectionView and below it a Button.
What's happening now:
- Focus engine is on a collection View
- User scrolls down
- Focus engine goes to next collection view unless I'm on the last item of the focused collection view, then it goes to VoirTout button.
What I want is:
- Focus engine is on a collection View
- User scrolls down
- Focus engine goes to Voir Tout Button
I have seen a couple of answers that make use of preferredFocusEnvironments like this:
// Trying to force focus on button
var voirToutButton: CustomButton? = CustomButton(color: .red, titleString: "");
override var preferredFocusEnvironments : [UIFocusEnvironment] {
return [voirToutButton!]
}
And then calling these inside viewDidLoad:
// TRYING TO FORCE FOCUS ON VOIR TOUT BUTTON
setNeedsFocusUpdate()
updateFocusIfNeeded()
But, in my case that had no effect.

I solved it like this. I'm not sure this is the most optimal way but it works: