So I'm running into a similar problem but on an SKScene where I'm planning to have home scene for my game, which has two buttons. I created a function to return the buttons to add to the scene and I tried the following code, and I can see that it changes colors as I planned, between green and yellow based on what seems to be the currently focused button. BUT, pressing the "Select" on the TV remote doesn't do anything so the buttonAction function is not called AND I even tested the values of the buttons to see if they're "focusable" but that returns false. See below:
func createAndReturnUIButton(pImageName: String, pNodeName: String, pFrame: CGRect) -> UIButton {
let btnNode = UIButton(frame:pFrame)
btnNode.backgroundColor = UIColor.clearColor()
btnNode.setTitle(pNodeName, forState: UIControlState.Normal)
btnNode.setTitleColor(
UIColor.greenColor(), forState: UIControlState.Normal)
btnNode.setTitleColor(
UIColor.yellowColor(), forState: UIControlState.Focused)
btnNode.addTarget(self, action: "buttonAction",
forControlEvents: UIControlEvents.TouchDown)
self.view!.addSubview(btnNode)
return btnNode
}
print("UIScreen.mainScreen().focusedView: \(UIScreen.mainScreen().focusedView)\nbtnEasyStart.focused:\(btnEasyStart.focused)\nbtnHardStart.focused:\(btnHardStart.focused)")
focusedView returns nil while the focused value of both buttons returns false.
Any idea what's wrong? Input is appreciated.
Thanks!