メソッドでは、viewDidLoad
userTrackingModeをに設定しましたMKUserTrackingModeFollowWithHeading
。いくつかのアノテーションとオーバーレイをmapviewに追加した後、mapviewデリゲートメソッドmapView:didChangeUserTrackingMode:animated:
が起動されます。その後、mapviewuserTrackingModeがに戻りMKUserTrackingModeFollow
ます。なんで?
コードは次のとおりです。
.......
[self.pMapView addOverlay: self.pPolyline];
.......
[self.pMapView setRegion:region animated:YES];
いくつかの注釈を削除しましたが、userLocationは削除しませんでした。
- (void) removeAllAnnotationsExceptUserLocationAndDestinAnnotation
{
for (id<MKAnnotation> annotation in [[self.pMapView.annotations copy] autorelease])
{
if ([annotation isMemberOfClass: [MKUserLocation class]]) continue;
CLLocationDegrees anLat = [self latitudeOfDestination];
CLLocationDegrees anLon = [self longitudeOfDestination];
if (anLat == annotation.coordinate.latitude && anLon == annotation.coordinate.longitude)
{
continue;
}
[self.pMapView removeAnnotation: annotation];
}
}