【问题标题】:Is there a way to detect if the user clicks on the right or left side of the Apple tv remote?有没有办法检测用户是点击 Apple tv 遥控器的右侧还是左侧?
【发布时间】:2017-10-27 08:39:17
【问题描述】:

我可以通过覆盖pressesEnded 方法来检测按下,但我如何才能找到用户按下遥控器的右侧还是左侧?

【问题讨论】:

    标签: tvos apple-tv


    【解决方案1】:

    可以通过检查压力机类型来检测定向敲击:

        override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
            for press in presses {
                switch press.type {
                case .upArrow:
                    print("⬆️")
                case .downArrow:
                    print("⬇️")
                default:
                    super.pressesBegan(presses, with: event)
                }
            }
        }
    

    另一方面,定向点击需要使用 GameControler SDK,你可以在这里找到它的解释:https://medium.com/@dcordero/directional-clicks-on-tvos-c711a2faf71a

    【讨论】:

    • 这似乎不再起作用了,我试图在我的本地运行你的项目,但它总是在守卫时返回 let controller = GCController.controllers().first else { return }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-06
    • 1970-01-01
    • 2010-12-06
    相关资源
    最近更新 更多