0
我有一個按鈕,如果按下我希望它獲得用戶的位置,並在其上放下注釋。但似乎我只按一次,它會在海洋中間添加註釋,然後出現我的用戶位置(這是有效的)。我第二次按它,它在我的位置添加註釋。iOS - MKMapView - Buggy註釋
代碼:
mapView.showsUserLocation = YES;
MKCoordinateRegion newRegion;
newRegion.center.latitude = mapView.userLocation.location.coordinate.latitude;
newRegion.center.longitude = mapView.userLocation.location.coordinate.longitude;
newRegion.span.latitudeDelta = 0.0004f;
newRegion.span.longitudeDelta = 0.0004f;
[mapView setRegion: newRegion animated: YES];
CLLocationCoordinate2D coordinate;
coordinate.latitude = mapView.userLocation.location.coordinate.latitude;
coordinate.longitude = mapView.userLocation.location.coordinate.longitude;
MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
[annotation setCoordinate: coordinate];
[annotation setTitle: @"Your Car"];
[annotation setSubtitle: @"Come here for pepsi"];
[mapView addAnnotation: annotation];
[mapView setZoomEnabled: YES];
[mapView setScrollEnabled: YES];
嘿男人謝謝! – 2012-08-12 09:47:39