想读的经度和纬度时,在iOS地图的地方,用户触摸(TAP),我想那个特定的(用户敲击的地方)的地方经纬度点。 (对于(例)如果用户触摸IOS总行意味着我要展现的ios总部地点的经度和纬度点)。 我怎样才能做到这一点。 任何一个可以帮我解决这个问题。
Answer 1:
覆盖触摸处理程序( touchesBegan
或UITapGestureRecognizer
),然后使用- (CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(UIView *)view
中MKMapView
,类引用在这里 。 然后加入适当的注释,以使用一个类符合地图MKAnnotation
协议,例如MKPinAnnotationView
。
因此,一个示例触摸处理方法看起来是这样的:
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
CGPoint pt = [[touches anyObject]locationInView:self.mapView];
CLLocationCoordinate2D latLong = [self.mapView convertPoint:pt toCoordinateFromView:self.mapView];
//add code here for annotation
}
然后添加注释-本教程http://www.raywenderlich.com/21365/introduction-to-mapkit-in-ios-6-tutorial应帮助您觉得─有在同一地点的iOS5的版本,以及。
文章来源: Ios Map: Getting latitude and longitude