如何在 tvOS 上检测 UIViewController 上的触摸

How to detect touches on UIViewController on tvOS

我正在为 tvOS 上的 Apple TV 制作一款跳跃游戏。我想知道用户何时触摸 UIViewController 中的遥控器。触摸开始(角色向上跳跃)和触摸结束(角色向下坠落)时的动作。

Apple 文档站点上的几乎所有手势示例都是针对单击的,而不是简单的触摸不按。有谁知道如何在 Swift for tvOS 中执行此操作?

您可以像 iOS 一样使用 touchesBegantouchesEnded