iphone - 模拟一个水龙头,可以吗?

标签 iphone objective-c

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

最佳答案

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

关于iphone - 模拟一个水龙头,可以吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5160952/

相关文章:

iphone - 在 init 中声明 block 安全吗?

ios - locationManager 'didExitRegion' 没有被调用 iBeacon Xcode

iphone - 带子项的 UIView 上的 TouchUpInside

iphone - 如何添加 NSViewBoundsDidChangeNotification

ios - 如何让生产签名的应用程序从 iOS 上的测试环境获取收据?

ios - 当应用程序后台运行然后恢复时,带有 HTML5 数据库的 UIWebView 不会加载

objective-c - NSImageCell:设置工具提示

iphone - 如何为我的 iOS 应用程序创建小部件?

处理设备照片时 iOS ImageView 裁剪不起作用

iphone - iOS >4.0 中的 locationServicesEnabled 始终显示 UIAlert