0

私のアプリケーションでは、ビューに Google マップを追加しました。

I want to know the touch point on the mapView / myView,どこで録音したの

そのため、次のようにロジックを実装しました。

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    CGPoint touchPoint  = [[touches anyObject] locationInView:mapView_];
     CGPoint touchPoint2  = [[touches anyObject] locationInView:self.view];



    NSLog(@"========== %@", NSStringFromCGPoint(touchPoint));
    NSLog(@"========== %@", NSStringFromCGPoint(touchPoint2));

   //UITouch *touch = [[event allTouches] anyObject];
     //CGPoint touchPoint = [touch locationInView:touch.view];

}

ただし、最初のタッチでのみ機能し、次のタッチ イベントからはこのメソッドは呼び出されません。

何が問題なのか分からなかった

4

2 に答える 2

0

これの助けを借りて、正確なタッチポイントでマップビューに触れるたびにログを取得します

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    CGPoint touchPoint  = [[touches anyObject] locationInView:self.viewMap];
    NSLog(@"==========1 %@", NSStringFromCGPoint(touchPoint));
}
于 2013-09-03T05:59:18.337 に答える
0

マップ上でタッチ位置を取得することはできません。タッチするとズームになり、タッチ イベントは UIView にあります。

于 2013-09-03T05:45:07.840 に答える