Search code examples
swiftuigesturerecognizertvosapple-tv

How to detect touches on UIViewController on tvOS


I am making a jumping game for the Apple TV on tvOS. I'd like to know when the user touches the remote in a UIViewController. An action for when the touch begins (character jumps upwards) and when it ends (character falls downwards).

Almost all gesture examples on the Apple documentation site are for clicking, not simply touching without pressing. Does anyone know how to do this in Swift for tvOS?


Solution

  • You can use touchesBegan and touchesEnded just like on iOS.