【发布时间】:2011-07-06 20:47:43
【问题描述】:
我知道可以拦截屏幕上的点击,但我想知道是否可以模拟屏幕上的点击(使用 x 和 y 坐标)。 谢谢
【问题讨论】:
标签: iphone objective-c
我知道可以拦截屏幕上的点击,但我想知道是否可以模拟屏幕上的点击(使用 x 和 y 坐标)。 谢谢
【问题讨论】:
标签: iphone objective-c
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
【讨论】:
如果是非越狱设备,请检查: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?
【讨论】: