Siri Remote's Menu Button Not Exiting Application When UIbutton Is Focused

Siri Remote's Menu Button not exiting application when UIButton is focused

UIButton only responds to the .Select button on the remote. You can catch the menu button using a tap gesture recognizer. For example:

let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(ClassName.menuPressed()))
tapRecognizer.allowedPressTypes = [NSNumber(integer: UIPressType.Menu.rawValue)];
view.addGestureRecognizer(tapRecognizer)

Then implement:

func menuPressed() {
// do something
}

Allow Siri Remote Menu button when Play/Pause button is overridden

To return to the Apple TV home screen you can setup a UITapGestureRecognizer in your viewDidLoad like so:

// Setup Menu Button recognizer
let menuGesture = UITapGestureRecognizer(target: self, action: #selector(ViewController.handleMenuGesture(_:)))
menuGesture.allowedPressTypes = [NSNumber(integer: UIPressType.Menu.rawValue)]
self.view.addGestureRecognizer(menuGesture)

and then in handleMenuGesture you suspend your application:

// MARK: - Handle Siri Remote Menu Button
func handleMenuGesture(tap: UITapGestureRecognizer) {
print("Menu Gesture")
UIControl().sendAction(#selector(NSURLSessionTask.suspend), to: UIApplication.sharedApplication(), forEvent: nil)
}

Related: Siri Remote's Menu Button not exiting application when UIButton is focused

Apple TV - Menu button returns to wrong screen

Two possible options:

  • Instead of presenting LandingPageViewController from SplashViewController, you could set LandingPageViewController as rootViewController. That way your splash will not be in your backstack of viewcontrollers.
  • Present SplashViewController in a separate window over LandingPageViewController. Once your video finishes you can dismiss the window.

Xcode UI Testing Remote Button Error: Failed to find focused element

This is a problem with your app code. When you move to a new view on Apple TV, the focused element should be set on the new view.

Your error indicates that no element has been given focus after you press the button.

Focus enables users to see what is currently selected and should involve some sort of visual indication, like having the focused view move towards the user in the Z-axis.

Unable to mimic Corner Taps of Siri remote in my game UI for Apple TV

Okay I found the solution for my problem, Here the issue was with Xib files and trying to use siri's focus api for up,down,left and right taps(not swipes). No matter how much I tried to hack it to make them functional the end result was nothing.

So I moved all my Xib's functionality to StoryBoard and voila! every thing started working. So, as far as I know and according to my research we should use Storyboards to get full functionality of the TvOS features that includes Siri Remote as well.
Here is what I did in my interface Builder Sample Image

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
_viewController =[storyboard instantiateInitialViewController];

How can I force focus to change to a specific view in tvOS?

Finally figured it out myself. You have to override the preferredFocusedView property of your UIView or UIViewController.

In Swift it works like this:

func myClickHandler() {
someCondition = true
self.setNeedsFocusUpdate()
self.updateFocusIfNeeded()
someCondition = false
}

override weak var preferredFocusedView: UIView? {
if someCondition {
return theViewYouWant
} else {
return defaultView
}
}

I can't quite remember how to override getters in Objective-C so if someone want to post that I'll edit the answer.



Related Topics



Leave a reply



Submit