Object-C中获取当前触摸点的坐标位置

  1. //当有一个或多个手指触摸事件在当前视图或window窗体中响应  
  2. -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event  
  3. {  
  4.     NSSet *allTouches = [event allTouches];    //返回与当前接收者有关的所有的触摸对象  
  5.     UITouch *touch = [allTouches anyObject];   //视图中的所有对象  
  6.     CGPoint point = [touch locationInView:[touch view]]; //返回触摸点在视图中的当前坐标  
  7.     int x = point.x;  
  8.     int y = point.y;  
  9.     NSLog(@"touch (x, y) is (%d, %d)", x, y);  
  10. }  
原文链接:http://blog.csdn.net/enuola/article/details/7900518

猜你喜欢

转载自blog.csdn.net/howlong12345/article/details/51482791