【发布时间】:2011-09-18 07:01:56
【问题描述】:
我的 MKMapView 会在启动时显示我的位置,但图像永远不会“跟随”我。位置更新,屏幕跟随我,但原始的“用户位置”图像留在后面。
这里是一些代码sn-ps:
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString* AnnotationIdentifier = @"Annotation";
MKPinAnnotationView *pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier];
if(!pinView)
{
MKPinAnnotationView *customPinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease];
if(annotation == mapView.userLocation) customPinView.image = [self rotate:[UIImage imageNamed:@"myCar.png"] orientation:UIImageOrientationUp];
else customPinView.image = [UIImage imageNamed:@"randomPin.png"];
customPinView.animatesDrop = NO;
customPinView.canShowCallout = YES;
return customPinView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
-(void)locationUpdate:(CLLocation *)location
{
CLLocationCoordinate2D loc = [location coordinate];
if(isFollowing)
[myMapView setCenterCoordinate:loc];//Works
}
在我的viewDidLoad 中,我确实打电话给:[myMapView setShowsUserLocation:YES];,这确实有效。
所以基本上在某个地方我忽略了更新我的位置,或者我最有可能为我的当前位置绘制新图像的位置。
谁能看到我在那里遗漏了什么或做错了什么,因为它没有关注我的位置更新?
谢谢。
【问题讨论】:
-
问题解决了吗?我有一个完全相同的。
-
抱歉,不记得了 - 发生的时间太长了
标签: iphone ios location mkmapview