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];
是的以上所有代码都有效! 终于搞定了。 因此,自动更新您的动作的自定义用户位置的步骤也在上面。
- glkView:drawInRect:和glkViewControllerUpdate之间的区别? OpenGL ES 2 – iOS
- 在View Controller之后,iOS块阻止exceptioncallback导致崩溃
- 几乎可以使自己成功的应用
- iOS中的视觉:文本检测和Tesseract识别
- 如何访问tableView的标准viewForHeaderInSection?
- 错误:git-credential-osxkeychain死于信号11
- 计算最大的字体大小,适合一个矩形?
- 如何在popup窗口之后停止UITableView返回顶部单元格
- 如何解决UITableViewController指定的初始化错误?