我正在尝试制作一个应用程序,要求用户记录他们当前的位置,然后让 pin 留在那里。因此,如果我有一个地图视图,我将有一个地图视图,然后在屏幕底部有一个按钮,允许用户在他们当前位置的位置放置一个图钉。
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 800, 800);
[self.mapview setRegion:[self.mapview regionThatFits:region] animated:YES];
// Add an annotation
MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
point.coordinate = userLocation.coordinate;
point.title = @"Where am I?";
point.subtitle = @"I'm here!!!";
[self.mapview addAnnotation:point];
}
我已经使用该代码在我当前位置的位置放置了一个图钉,但我需要在点击按钮后进行。我还需要那个别针留在他们敲击它的地方,所以如果他们在别针上移动,就会留在他们敲击它的地方。
谢谢你的帮助!