Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to invoke TouchesBegan, TouchesMoved, TouchedEnded programmatically

Is there a way to invoke TouchesBegan, TouchesMoved, TouchedEnded programmatically ??

like image 439
Rajavanya Subramaniyan Avatar asked Feb 27 '23 15:02

Rajavanya Subramaniyan


2 Answers

No, you can't. Unfortunately, UIEvent doesn't expose any public way to create events; only the internal dispatcher is allowed to do that. You can't cook up your own events from scratch and use them in a meaningful way.

Sounds like you might be able in your application to forward the events-- by taking them from the place where they land originally, and just sending them to the view that you want to consume them by calling those methods directly. Depending on what those views are, make sure you fully understand the event dispatch sequence (hit testing etc), though, so you don't confuse UIKit views.

like image 167
Ben Zotto Avatar answered Apr 09 '23 13:04

Ben Zotto


It's just a method so you could call it and create the events yourself I assume (assumptions are bad though). If you are trying to trigger your own touchesX code it would seem easier to just move that to its own method and call it straight away.

Exactly what are you trying to achieve?

like image 27
willcodejavaforfood Avatar answered Apr 09 '23 12:04

willcodejavaforfood