我试图在用户单击Apple TV遥控器上的暂停/播放按钮时创建操作。我查看了文档,但Apple推荐的文档代码不起作用。以下是我的代码如下。有人能告诉我我做错了什么吗?需要考虑的事项: 我正在使用AVPlayerMovieController &我的代码中有另一个手势识别器,但它是一个轻扫手势,此方法正在调用,而不是暂停/播放。有人可以帮忙吗?UITapGestureRecognizer&tvOS遥控器用于暂停/播放按钮
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
tap.allowedPressTypes = @[[NSNumber numberWithInteger:UIPressTypePlayPause]];
[self.view addGestureRecognizer:tap];
谢谢
如果您的视图已经在检测按下按钮(例如UICollectionViewCell等),它将起作用(无需添加UITapGestureRecognizer)。所有其他条件相同,最简单的解决方案应该是选定的答案(这一个)。对于其他人,您可以添加点按手势识别器,并允许按下UIPressType.PlayPause按钮。请参阅https://developer.apple.com/library/tvos/documentation/General/Conceptual/AppleTV_PG/DetectingButtonPressesandGestures.html – skim