在iOS7上注入系统范围的触摸事件 [英] Inject system wide touch events on iOS7
问题描述
在iOS7之前,可以使用 GSSendSystemEvent
和 GSSendEvent
私有API调用注入触摸事件,例如:
Prior to iOS7 it was possible to inject touch events with the GSSendSystemEvent
and GSSendEvent
private API calls, eg:
- GSSendEvent - Inject Touch Event iOS
- Simulating System Wide Touch Events on iOS
- System-wide tap simulation on iOS
- Send a global touch event on iOS 6
在iOS7上这些来电似乎默默地失败了。 在iOS 7中模拟系统范围的触摸中提出了另一种选择但它只适用于越狱设备。 https://github.com/kif-framework/KIF 看起来像另一种选择,但它似乎它只支持为当前应用程序而不是系统范围注入事件(例如,当你的应用程序在后台时,你无法注入触摸事件)。
On iOS7 these calls seem to silently fail though. An alternative has been suggested in Simulating system-wide touches in iOS 7 but it only works on jailbroken devices. https://github.com/kif-framework/KIF looks like another option, but it appears that it only supports injecting events for the current app rather than system wide (so you couldn't inject a touch event while you're app is in the background, for example).
那么如何在没有越狱的情况下在iOS7上注入系统范围的触摸事件?
So how can you inject system wide touch events on iOS7, without a jailbreak?
推荐答案
我假设您需要在系统范围内为测试场景做这个吗?在这种情况下,Apple的 UI Automation 框架可以为您提供良好的服务,这是一个基于JavaScript的工具,可用于设备上测试。
I assume you need to do this system-wide for a testing scenario? In which case you might be well served by Apple's UI Automation framework, a JavaScript-based tool useful for on-device testing.
当你不能像模拟主页按钮那样做,你可以将你的应用程序发送到后台指定的持续时间,例如:
While you can't do things like simulate a home-button press, you can send your app to the background for a specified duration, for example:
UIATarget.localTarget()。deactivateAppForDuration(秒);
以下是文档:
这篇关于在iOS7上注入系统范围的触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!