MKMapView iOS自定义用户位置注释未显示/更新位置

嗨我正在使用自定义注释来代替蓝色GPS位置点。 我在viewForAnnotation中将它添加到地图中。 OurLocAnnotation类符合MKAnnotation委托。

//Custom location view if([annotation isKindOfClass:[OurLocAnnotation class]]) { static NSString *identifier = @"currentLocation"; SVPulsingAnnotationView *pulsingView = (SVPulsingAnnotationView *)[self.recycleMap dequeueReusableAnnotationViewWithIdentifier:identifier]; if(pulsingView == nil) { pulsingView = [[SVPulsingAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; pulsingView.annotationColor = [UIColor colorWithRed:0.678431 green:0 blue:0 alpha:1]; pulsingView.canShowCallout = YES; } return pulsingView; } 

根据此链接将显示用户位置设置为NO:从viewDidLoad调用上一个stackoverflow问题并开始更新位置

我遇到的问题是注释没有显示我是否需要四处移动才能启动并更新我的位置,或者我可以在加载时设置其状态,即显示注释然后将注释更新到我的位置? 如果我给出了注释硬编码的坐标值,但是我不想根据我的位置想要它吗?

 - (void) locationManager:(CLLocationManager*) manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation { if (ourLocAnn == nil) { self.ourLocAnn = [[OurLocAnnotation alloc] init]; ourLocAnn.title = @"I am here"; ourLocAnn.coordinate = newLocation.coordinate; [recycleMap addAnnotation:ourLocAnn]; } else { ourLocAnn.coordinate = newLocation.coordinate; } 

更新:我很愚蠢我可以通过向位置经理询问我的位置来显示我的位置,如下所示。 我一定希望我移动时我的位置会更新….

 ourLocAnn = [[OurLocAnnotation alloc]init]; ourLocAnn.coordinate = clController.locMgr.location.coordinate; [recycleMap addAnnotation:ourLocAnn]; 

是的以上所有代码都有效! 终于搞定了。 因此,自动更新您的动作的自定义用户位置的步骤也在上面。