您的位置:首页 > 移动开发 > IOS开发

【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);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: