- (void)viewDidLoad
{
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(foundTap:)];
tapRecognizer.numberOfTapsRequired = 1;
tapRecognizer.numberOfTouchesRequired = 1;
[self.myMapView addGestureRecognizer:tapRecognizer];
}
-(void)foundTap:(UITapGestureRecognizer *)recognizer
{
CGPoint point = [recognizer locationInView:self.myMapView];
CLLocationCoordinate2D tapPoint = [self.myMapView convertPoint:point toCoordinateFromView:self.view];
MKPointAnnotation *point1 = [[MKPointAnnotation alloc] init];
point1.coordinate = tapPoint;
[self.myMapView addAnnotation:point1];
}
我用上面的代碼來做出的MKMapView針點時,我選擇的MKMapView的地方它不地步,我正好touches.It遠遠有點其中i touches.What我的代碼錯了嗎?。任何幫助將不勝感激。提前感謝。情節銷不上的MKMapView
感謝UR answer.it工作正常 – Xcode
我如何獲得的MKMapView選擇位置的經度和緯度值? – Xcode
在你的情況下,你會做:tapPoint.latitude和tapPoint.longitude或point1.coordinate.latitude和point1.coordinate.longitude。請參閱http://developer.apple.com/library/mac/#documentation/CoreLocation/Reference/CoreLocationDataTypesRef/Reference/reference.html – Stunner