开发者

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 coordi开发者_运维技巧nates). Thanks


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


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜