Object-Cで現在のタッチポイントの座標位置を取得

432 ワード

//                   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);
}