Ios 什么会导致MKMapView更改它';用户跟踪模式?
在Ios 什么会导致MKMapView更改它';用户跟踪模式?,ios,mkmapview,Ios,Mkmapview,在viewDidLoad方法中,我已将userTrackingMode设置为MKUserTrackingModeFollowWithHeading。 在向mapview添加一些注释和覆盖后,mapview委托方法mapview:didChangeUserTrackingMode:animated:被激发。然后mapview userTrackingMode返回到MKUserTrackingModeFollow。为什么? 代码如下: ....... [self.pMapView addOv
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];
}
}
-(void)删除AllAnnotation seceptuserLocation和DestinanNotation
{
对于(在[[self.pMapView.annotations copy]autorelease]中的id注释)
{
如果([annotation isMemberOfClass:[MKUserLocation class]])继续;
CLLocationDegrees anLat=[自相关估计];
CLLocationDegrees anLon=[自纵向目标];
if(anLat==annotation.coordinate.latitude&&anLon==annotation.coordinate.longitude)
{
继续;
}
[self.pMapView removeAnnotation:annotation];
}
}
您正在删除批注吗?如果是,请确保您没有删除userLocation注释。为什么要复制注释数组?因为当它循环时,其他一些方法可能会修改mapview的注释,这是为了线程安全。