swift - 如何访问 Siri Remote 播放/暂停按钮和覆盖菜单按钮

标签 swift tvos uitapgesturerecognizer siri-remote

如何使用 Siri Remote 访问播放/暂停按钮并覆盖菜单按钮?我目前正在使用这个,但它对我不起作用。当我使用此代码时,我的程序崩溃,但仅当我调用它时,按暂停按钮四个示例 编码器当前位于 didMoveToView 下面,靠近 TouchBegan

let tapGesture = UITapGestureRecognizer(target: self, action: "handleTap:")
tapGesture.allowedPressTypes = [NSNumber(integer: UIPressType.Menu.rawValue)]
self.view.addGestureRecognizer(tapGesture)

最佳答案

您的问题是您正在调用一个名为 handleTap: 的函数,该函数接收参数,但您没有名为 handleTap: 的函数。这就是 action 在这一行中所代表的内容:

let tapGesture = UITapGestureRecognizer(target: self, action: Selector("handleTap:"))

将您的func tapped()更改为:

func handleTap(sender: UITapGestureRecognizer) {
    if sender.state == UIGestureRecognizerState.Ended {
        print("Menu button released")
    }
}

关于swift - 如何访问 Siri Remote 播放/暂停按钮和覆盖菜单按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36812636/

相关文章:

ios - 如何检测是否点击了 UI 标签?

ios - 将图像从 Firebase 加载到我的 TableView 时出错

ios - 如何更改 UICollectionView zIndex?

debugging - tvOS 中是否有用于 Focus Engine 调试的隐藏工具?

swift - 如何在SpriteKit中检测远程点击并传递节点信息

swift - 点击切换 UIViews 类

ios - 如何检测对 UICollectionView 中单元格的双击

ios - NSNotificationCenter postNotificationName 在 swift 和 object-c 中崩溃,为什么?

swift - 将 DAAppearanceTime 转换为日期

ios - UIButton 导致崩溃