【iOS学习笔记】获取点击屏幕坐标
2015-05-08 08:55
337 查看
//当有一个或多个手指触摸事件在当前视图或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;
int y = point.y;
NSLog(@"touch (x, y) is (%d, %d)", x, 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;
int y = point.y;
NSLog(@"touch (x, y) is (%d, %d)", x, y);
}
相关文章推荐
- 【IOS学习笔记】为UICollectionView设置自适应屏幕宽度以及点击效果
- iOS开发- 根据表格点击tableviewCell获取在当前屏幕中的坐标值
- IOS网络笔记--地图内容3(点击获取当前地址的具体坐标)
- ios学习笔记: IOS8解决获取位置坐标信息出错(Error Domain=kCLErrorDomain Code=0)
- iOS屏幕旋转学习笔记
- IOS学习笔记-获取当前的地理位置swift版
- 安卓学习笔记---获取屏幕的宽高以及屏幕密度,最小宽度等同时可以可以获取屏幕的不同dimens进行适配
- Android个人学习笔记之ListView知识应用-仿IOS百度云条目点击显示菜单模块实现
- iOS屏幕旋转学习笔记
- iOS屏幕旋转学习笔记
- iOS学习笔记(十三)——获取手机信息(UIDevice、NSBundle、NSLocale)
- 【OPEN GL】学习笔记之一:顶点坐标到屏幕坐标之间的转换
- Cocos2dx学习之-----关于拖动缓冲,点击屏幕获取方向
- 【IOS移动开发技术】iOS软件开发中关于屏幕旋转处理相关的学习笔记
- 百度地图SDK for Android【Demo点击屏幕获取地理坐标】
- 百度地图SDK for Android【Demo点击屏幕获取地理坐标】
- IOS学习笔记(十三)——获取手机信息(UIDevice、NSBundle、NSLocale)
- IOS学习笔记之获取Plist文件读取数据
- Unity中UGUI中获取鼠标点击位置以及UI物体的屏幕坐标
- iOS学习笔记20-通过AirServer使用AirPlay镜像并实现多屏幕显示控制