这是我得到的:
- (MKAnnotationVIEw *)mapVIEw:(MKMapVIEw *)mapVIEw vIEwForAnnotation:(ID <MKAnnotation>)annotation{ MKPinAnnotationVIEw *pinVIEw = (MKPinAnnotationVIEw *)[mapVIEw dequeueReusableAnnotationVIEwWithIDentifIEr:@"pinVIEw"]; if (!pinVIEw && ![annotation isKindOfClass:[MKUserLocation class]]) { pinVIEw = [[MKPinAnnotationVIEw alloc] initWithAnnotation:annotation reuseIDentifIEr:@"pinVIEw"]; pinVIEw.pincolor = MKPinAnnotationcolorRed; pinVIEw.animatesDrop = YES; pinVIEw.canShowCallout = YES; UIbutton *rightbutton = [UIbutton buttonWithType:UIbuttonTypeDetaildisclosure]; pinVIEw.rightCalloutAccessoryVIEw = rightbutton; if (annotation == self.locationZH1) { [pinVIEw setTag:1]; } else if (annotation == self.locationZH2) { [pinVIEw setTag:2]; } else if (annotation == self.locationZH3) { [pinVIEw setTag:3]; } else if (annotation == self.locationLU1) { [pinVIEw setTag:4]; } } else { pinVIEw.annotation = annotation; } return pinVIEw;}解决方法 请务必避免为内置用户位置标记提供注释视图.
- (MKAnnotationVIEw *)mapVIEw:(MKMapVIEw *)mapVIEw vIEwForAnnotation:(ID<MKAnnotation>)annotation{ //check annotation is not user location if([annotation isEqual:[mapVIEw userLocation]]) { //bail return nil; } static Nsstring *annotationVIEwReuseIDentifer = @"map_vIEw_annotation"; //dequeue annotation vIEw MKPinAnnotationVIEw *annotationVIEw = (MKPinAnnotationVIEw *)[mapVIEw dequeueReusableAnnotationVIEwWithIDentifIEr:annotationVIEwReuseIDentifer]; if(!annotationVIEw) { annotationVIEw = [[MKPinAnnotationVIEw alloc] initWithAnnotation:annotation reuseIDentifIEr:annotationVIEwReuseIDentifer]; } //set annotation vIEw propertIEs [annotationVIEw setAnnotation:annotation]; return annotationVIEw;}
通过先检查用户位置注释,您可以提前返回nil而不是分配新的MKPinAnnotationVIEw并返回它.
– (MKAnnotationVIEw *)mapVIEw的文档:(MKMapVIEw *)mapVIEw vIEwForAnnotation:(ID< MKAnnotation>)注释状态:
总结If the object in the annotation parameter is an instance of the MKUserLocation class,you can provIDe a custom vIEw to denote the user’s location. To display the user’s location using the default system vIEw,return nil.
以上是内存溢出为你收集整理的iOS:用户位置变为pin全部内容,希望文章能够帮你解决iOS:用户位置变为pin所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)