获取当前触摸点坐标
2015-08-23 10:03
232 查看
//当有一个或多个手指触摸事件在当前视图或window窗体中响应
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSSet *allTouches = [event allTouches]; //返回与当前接收者有关的所有的触摸对象
UITouch *touch = [allTouches anyObject]; //视图中的所有对象
CGPoint point = [touch locationInView:[touch view]]; //返回触摸点在视图中的当前坐标
int x = point.x;
//x轴坐标
int y = point.y;
//y轴坐标
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSSet *allTouches = [event allTouches]; //返回与当前接收者有关的所有的触摸对象
UITouch *touch = [allTouches anyObject]; //视图中的所有对象
CGPoint point = [touch locationInView:[touch view]]; //返回触摸点在视图中的当前坐标
int x = point.x;
//x轴坐标
int y = point.y;
//y轴坐标
}
相关文章推荐
- 九度 1105 - 字符串处理 - 字符串的反码
- 洛谷1443 马的遍历 解题报告
- java集合 之 Map集合
- 深入理解javascript之arguments
- ASP.NET Web API实践系列09,在Fiddler和控制台中模拟GET和POST请求
- Android(java)学习笔记188:关于构造代码块,构造函数的一道面试题(华为面试题)
- TCP/IP 是用于因特网 (Internet) 的通信协议。
- 输出字符指针的值
- 协议和代理
- c语言中 快速输出字符数组后几位方法
- c++ 不破坏类封装的回调函数构思
- sqlserver的几个常用转换
- (Android)Vuforia Native版本与jpct-ae结合
- C语言基础知识之(三):循环、随机数
- 6-06. 任务调度的合理性(25) -- 拓扑排序
- Matlab
- 洛谷1605 迷宫 解题报告
- Struts2学习(三)上传下载
- WSAEventSelect的使用
- Leetcode: Lowest Common Ancestor of a Binary Search Tree