How can I receive touches using tvOS with the simulator? We need know touch position. UIPress - have no it!
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event {
// Never called
}
-(void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event {
// Works fine!
}
With the Apple TV Remote in Control Center, you can control your Apple TV or AirPlay 2-compatible smart TV with your iPhone, iPad, or iPod touch.
Sign in with your Apple IDTo automatically add your Apple ID and Wi-Fi settings to your Apple TV, choose Set Up with iPhone. Then unlock your iPhone, hold it next to your Apple TV, and follow the onscreen steps on your iPhone and Apple TV.
Open the Control Center by swiping down from the top right of the screen. (If you are using iOS 11 or older, open the Control Center by swiping up from the bottom of the screen.) 2. Tap the Apple TV Remote button, which you'll find in the collection of buttons at the bottom of the screen.
Presses are related to physical buttons, like the Menu button. A press begins when you start holding down such a button, and it ends when you stop holding down the button. There isn't any screen-relative position associated with a press.
Touches in tvOS are similar to touches in iOS, but there's one important difference: they're "indirect" touches, i.e. there isn't a physical relationship between the location of the finger and a location on screen.
When a touches begins, it will be delivered to the focused view, and the touch will be considered to have started in the center of that view, regardless of the absolute position of the finger on the touch surface. As the touch moves, its screen-relative position will be updated accordingly.
I'm not aware of any API that would allow you to determine the absolute position of a finger on the touch surface.
In your case, making your responder the focused view should cause it to receive touch events.
I think it should be pressesBegan instead of touchedBegan.
(void)pressesBegan:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With