【问题标题】:Simulate a tap, is possible?模拟水龙头,可以吗?
【发布时间】:2011-07-06 20:47:43
【问题描述】:

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

【问题讨论】:

标签: iphone objective-c


【解决方案1】:
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

【讨论】:

  • 投反对票,因为 - 这种技术脱离了上下文,需要更多使用私有 API 的代码(在链接上)。
  • 赞成,因为 - 一般而言,合成触摸需要访问某种私有 API。
【解决方案2】:

如果是非越狱设备,请检查: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?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-30
    • 2014-10-04
    • 2010-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-14
    相关资源
    最近更新 更多