ios - 除了使用 GSEvent 来伪造 iOS 7 设备上的触摸事件之外,还有其他方法吗?

标签 ios objective-c ios7 uitouch

我需要在 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/

相关文章:

iphone - iTunes 评论 URL 和 iOS 7(要求用户评价我们的应用程序)AppStore 显示空白页面

ios - 在 iOS 7.1 中更改 UITabBarItem 角标(Badge)颜色

ios - 滚动表格 View 时单元格变为空白(快速)

ios - CLLocationManager 委托(delegate)方法未在后台调用

ios - 如何从主程序中检索 iOS 框架包中的文件/资源​​?

iphone - 将 NSArray 分隔为 NSString 类型对象的列表

iphone - 如何检查 NSString 是否包含 '%'?

ios - 将 UIViewController 嵌入静态 UITableViewController 单元格中

objective-c - 应用程序、辅助工具通讯

ios - 嵌入 NSTextAttachment 时高 UILabel 中缺少的行