获取触摸点的坐标位置
//触摸事件
-(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 (%i,%i)",x,y);
}
本文介绍了一个简单的iOS应用程序中处理触摸事件的方法。通过示例代码展示了如何在UIKit框架下使用UITouch来获取用户触摸屏幕时的位置坐标。
2832

被折叠的 条评论
为什么被折叠?



