可以模拟水龙头吗?

时间:2011-03-01 22:04:05

标签: iphone objective-c

我知道可以截取屏幕上的点击,但我想知道是否可以在屏幕上模拟点击(使用x和y坐标)。 感谢

2 个答案:

答案 0 :(得分:3)

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];

从这里开始 http://cocoawithlove.com/2008/10/synthesizing-touch-event-on-iphone.html

答案 1 :(得分:0)

如果它不是越狱设备,请检查以下内容:PTFakeTouch(适用于ios 11)。它仅在您的应用程序内部起作用。由于您使用的是专用API,因此您可能会被App Store拒绝。

如果要模拟系统范围内的触摸事件,则必须越狱设备。

检查以下链接以了解越狱设备:

Simulate Touch Event on iOS - jailbroken - iOS13+

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

相关问题