在iphone mkmapview中获取地图的当前位置

5 objective-c mapkit ios

如何根据用户在iPhone上触摸地图上的位置来获取mkmapview中的位置坐标?

Kun*_*jar 0

将 TapGesture 添加到您的地图视图并按照以下代码操作

-(void)didTouchMap:(UITapGestureRecognizer*)tapGesure {

         CGPoint touchPoint = [tapGesure locationInView:selectLocationMapView];
         CLLocationCoordinate2D coord= [selectLocationMapView convertPoint:touchPoint      toCoordinateFromView:selectLocationMapView];
         NSLog(@"lat  %f",coord.latitude);
         NSLog(@"long %f",coord.longitude);

}
Run Code Online (Sandbox Code Playgroud)