Community,
I have an overlay menu that displays when the user pressed the MENU button. The menu consists of some customized UIViews with animated states, etc. The menu itself is dyncamically rendered and desposited on screen at once in a loop, with each UIView returing TRUE from -canBecomeFocused. This has worked perfectly until I added a new UIView item, not rendered as part of this group (outside the loop). This item, is just a single button, and is supposed to appear like the ubiquitous hamburger menu - here's a diagram:
http://cl.ly/image/1D090Q2r1e0K
Once I add this last item - the app no longer allows me to move focus to the other UIViews - just this one "menu" item. What could be causing the focus system to ignore these other UIViews? Nothing is obscured? All frames are contained to the shape of the area of the selectable control.
I was able to correct this by adding a UIFocusGuide to adjust the search path of the focus engine, by looking at the source code in the Apple UIKit TvOS sample code:
This code here establishes a region the focus engine should scan for focusable objects (top left, bottom left, top right, height). Knowing this, the focus engine can hit all the items contained within that region:
focusGuide = UIFocusGuide()
view.addLayoutGuide(focusGuide)
/
focusGuide.leftAnchor.constraintEqualToAnchor(topRightButton.leftAnchor).active = true
focusGuide.topAnchor.constraintEqualToAnchor(bottomLeftButton.topAnchor).active = true
/
focusGuide.widthAnchor.constraintEqualToAnchor(topRightButton.widthAnchor).active = true
focusGuide.heightAnchor.constraintEqualToAnchor(bottomLeftButton.heightAnchor).active = trueThis code appears in the FocusGuidesViewController, in the Focus samples group