Can't move button focus to the next row

186 Views Asked by At

What I have here is 3 buttons. Btn2 is disabled. When Btn1 is focused, I can't move it to Btn3.

All what I need is when Btn2 is disabled, I can move between Btn1 and Btn3 by swiping down and up on the TV controller.

+----+
|Btn1|
+----+

+----+     +----+
|Btn2|     |Btn3|
+----+     +----+

I tried to implement the focus guide, but no luck

let focusGuide = UIFocusGuide()
view.addLayoutGuide(focusGuide)
focusGuide.topAnchor.constraint(equalTo: btn1.topAnchor).isActive = true
focusGuide.bottomAnchor.constraint(equalTo: btn3.bottomAnchor).isActive = true

What exact are topAnchor, bottomAnchor etc. about? There is no documentation on this. Please shed some light on. Thanks!

1

There are 1 best solutions below

0
On

I saw your questions and I wonder if you found the documentation of Auto Layout Constrants. It does exist.

If you didn’t find the Doc’s about this Class.

Here it is: https://developer.apple.com/documentation/uikit/uilayoutguide

Another tip to help you in the future, if you think is too confusing to do this programatically, try to use Storyboard and do it with Click and Drag “Methodology”.

Basically, you click on your Layout in Interface and Drag to a specific reference to create a constrants.

Don’t need to worry about Methods, Properties and Classes for Constrants.

Happy Coding.