我需要在 iOS 7 设备上伪造触摸事件。我浏览了一些可用资源,但找不到任何关于 iOS 7 的内容。
以下是我打算实现的目标:
在 iOS 7 设备上运行的 iOS 后台代码将监听套接字,客户端应用程序将向该套接字发送鼠标按键,这些按键被转换为触摸/滑动等事件。
我已经浏览了这个链接 http://blog.lazerwalker.com/blog/2013/10/16/faking-touch-events-on-ios-for-fun-and-profit同样,但这里也有人说 GSEvent 将在 iOS 7 中静默失败。
请让我知道是否有办法实现这一目标。
最佳答案
查看 ControlFreak .
所以添加并导入之后,就可以进行touch了
- (void)performTouchInView:(UIView *)view
{
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];
}
您也可以指定触摸点
UITouch *touch = [[UITouch alloc] initInView:view xcoord:100 ycoord:100];
关于ios - 除了使用 GSEvent 来伪造 iOS 7 设备上的触摸事件之外,还有其他方法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26881201/