什么会导致MKMapView改变它的userTrackingMode?

时间:2012-10-26 13:33:18

标签: ios mkmapview

viewDidLoad方法中,我将userTrackingMode设置为MKUserTrackingModeFollowWithHeading。 向mapview添加一些注释和叠加后,mapview委托方法mapView:didChangeUserTrackingMode:animated:被触发。然后mapview userTrackingMode返回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];
    }
}

0 个答案:

没有答案