当按遥控器上的菜单按钮时,Apple TV App无法从初始视图控制器退出到主屏幕 [英] Apple TV App not exiting to the home screen from initial view controller when menu button pressed on remote

查看:254
本文介绍了当按遥控器上的菜单按钮时,Apple TV App无法从初始视图控制器退出到主屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚因为

'此外,Siri Remote上的菜单"按钮在您的应用程序中的行为不正常. 具体来说,当用户启动该应用程序并点击Siri Remote上的菜单"按钮时,该应用程序不会退出到Apple TV主屏幕.'

'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?

我想我可以拦截菜单按钮的按下并调用exit(0),但这似乎不是退出的一种优美方式.

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.

推荐答案

我也有一个因为这个原因而被拒绝的应用.在我的情况下,问题是覆盖了press<Phase>d:withEvent组方法而没有调用super实现.

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.

所以我改变了这个:

-(void)pressesBegan:(NSSet*)presses withEvent:(UIPressesEvent *)event {
    // my code
}

对此:

-(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
}

然后菜单按钮再次起作用.令人困惑的是,无论您是否呼叫super,主页"按钮都将继续起作用.

And the menu button works again. What's confusing is that the Home button continues to work whether you call the super or not.

这篇关于当按遥控器上的菜单按钮时,Apple TV App无法从初始视图控制器退出到主屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆