I've just had an Apple TV app rejected because of
'In addition, the Menu button on the Siri Remote does not behave as expected in your app. Specifically, when the user launches the app and taps the Menu button on the Siri Remote, the app does not exit to the Apple TV Home screen.'
I'm looking this up and from what I can tell this should be the automatic behaviour of pressing the menu button when on the initial view controller. However I have a navigation controller with a root view controller, instantiated automatically via the storyboard with no methods overridden and nothing happens when I press the menu button on this view controller.
Can someone tell me if I'm missing something or if there's a way of implementing this manually?
I'm thinking I could just intercept the menu button press and call exit(0), but that doesn't seem like a graceful way of exiting.
I just had an app rejected for this reason too. In my case the problem was overriding the press<Phase>d:withEvent
group of methods without calling the super
implementation.
So I changed this:
-(void)pressesBegan:(NSSet*)presses withEvent:(UIPressesEvent *)event {
// my code
}
To this:
-(BOOL)ignoreMenu:(NSSet*)presses {
return ((UIPress *)[presses anyObject]).type == UIPressTypeMenu;
}
-(void)pressesBegan:(NSSet*)presses withEvent:(UIPressesEvent *)event {
if ([self ignoreMenu:presses]) return [super pressesBegan:presses withEvent:event];
// my code
}
And the menu button works again. What's confusing is that the Home button continues to work whether you call the super
or not.
My complete working code as of tvOS 9.1 (compiled under Objective-C++)
bool AppRespondedToBack = false;
-(void)pressesBegan:(NSSet*)presses withEvent:(UIPressesEvent *)event
{
UIPress *UP = (UIPress *)presses.anyObject;
if ( UP && UP.type == UIPressTypeMenu )
{
//OnBack should be where you handle the back operation in your app
AppRespondedToBack = OnBack();
if ( !AppRespondedToBack )
// Let AppleTV return to the home screen
[super pressesBegan:presses withEvent:event];
}
else
[super pressesBegan:presses withEvent:event];
}
-(void)pressesEnded:(NSSet*)presses withEvent:(UIPressesEvent *)event
{
UIPress *UP = (UIPress *)presses.anyObject;
if ( UP && UP.type == UIPressTypeMenu )
{
if ( !AppRespondedToBack )
// Let AppleTV return to the home screen
[super pressesEnded:presses withEvent:event];
}
else
[super pressesEnded:presses withEvent:event];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With