如何停止viewForAnnotation方法覆盖iOS中的默认用户位置蓝色信标

如何停止viewForAnnotation方法覆盖iOS中的默认用户位置蓝色信标,第1张

概述现在我用填充填充地图视图,并显示用户的当前位置.使用viewForAnnotation方法,它会使用默认的红色引脚覆盖所有注释,但是我想返回其他注释的视图,但将用户位置保留为默认的蓝色信标.有没有办法这样做,或者我必须创建一个新的注释视图,并根据注释返回正确的? 现在我有这样的东西: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewFo 现在我用填充填充地图视图,并显示用户的当前位置.使用vIEwForAnnotation方法,它会使用默认的红色引脚覆盖所有注释,但是我想返回其他注释的视图,但将用户位置保留为默认的蓝色信标.有没有办法这样做,或者我必须创建一个新的注释视图,并根据注释返回正确的?

现在我有这样的东西:

- (MKAnnotationVIEw *)mapVIEw:(MKMapVIEw *)mapVIEw vIEwForAnnotation:(ID <MKAnnotation>)annotation{    if (annotation.coordinate == locationManager.location.coordinate) {return nil;    }else {    MKAnnotationVIEw *annotationVIEw = [[MKPinAnnotationVIEw alloc] initWithAnnotation:annotation reuseIDentifIEr:@"Beacon"];    // button    UIbutton *button = [UIbutton buttonWithType:UIbuttonTypeDetaildisclosure];    button.frame = CGRectMake(0,23,23);    annotationVIEw.rightCalloutAccessoryVIEw = button;    annotationVIEw.canShowCallout = YES;    return annotationVIEw;}}

但是我不能等于两个,因为我不能从坐标参数中获取坐标属性.

有谁知道任何解决方案吗?

解决方法 在这里查看文档:

http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapViewDelegate_Protocol/MKMapViewDelegate/MKMapViewDelegate.html

正如它所说:

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.

所以你可以添加一个条件来检查:

if([annotation isKindOfClass: [MKUserLocation class]]) {  return nil;}
总结

以上是内存溢出为你收集整理的如何停止viewForAnnotation方法覆盖iOS中的默认用户位置蓝色信标全部内容,希望文章能够帮你解决如何停止viewForAnnotation方法覆盖iOS中的默认用户位置蓝色信标所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1112579.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存