Andrea
Andrea

Reputation: 1721

Simulate a tap, is possible?

I know that is possible to intercept a tap on a screen, but I want to know if is it possible to simulate a tap in a point of screen (with x and y coordinates). Thanks

Upvotes: 8

Views: 13373

Answers (2)

Jason Z
Jason Z

Reputation: 39

If it is a non-jailbroken device, check this: PTFakeTouch (worked for ios 11). It only works inside your applications. Since you are using private APIs, you might get rejected from the App Store.

If you want to simulate system-wide touch events, you have to jailbreak your device.

Check these links for jailbroken devices:

Simulate Touch Event on iOS - jailbroken - iOS13+

Is possible to simulate touch event using an external keyboard on ios jailbroken?

Upvotes: 1

madmik3
madmik3

Reputation: 6983

UITouch *touch = [[UITouch alloc] initInView:view];
UIEvent *eventDown = [[UIEvent alloc] initWithTouch:touch];

[touch.view touchesBegan:[eventDown allTouches] withEvent:eventDown];

[touch setPhase:UITouchPhaseEnded];
UIEvent *eventUp = [[UIEvent alloc] initWithTouch:touch];

[touch.view touchesEnded:[eventUp allTouches] withEvent:eventUp];

[eventDown release];
[eventUp release];
[touch release];

from here http://cocoawithlove.com/2008/10/synthesizing-touch-event-on-iphone.html

Upvotes: 3

Related Questions