PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, September 29, 2022

[FIXED] How to prevent game controller button B from quitting app / navigating back to menu in tvOS

 September 29, 2022     gamecontroller, tvos     No comments   

Issue

The game controller button B is, by default, quitting the app and navigating back to the tvOS home screen. At first I thought this was intuitive, but quickly realized that's what the Nimbus MENU button (dead middle of the controller) is for, and that I actually want to use button B in-game.

Setting a change handler for button B works, but the app still quits when the button is released.

GCControllerButtonValueChangedHandler buttonBHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
        NSLog(@"B");
};

Solution

I had the same issue.

The solution was to have my main ViewController inherit from GCEventViewController instead of UIViewController.

By default, when using GCEventViewController, the MENU button will not return to the menu. In this case, if you want it to be able to return to the menu with the original behavior you can simply set controllerUserInteractionEnabled to YES.

see the documentation for this class here : https://developer.apple.com/library/tvos/documentation/GameController/Reference/GCEventViewController_Ref/index.html

edit : apple dev forum helpep me fix this issue : https://forums.developer.apple.com/message/57926#57926

hope this helps,



Answered By - François Pilote
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing