Ios 用户位置显示与注释类似

Ios 用户位置显示与注释类似,ios,annotations,userlocation,Ios,Annotations,Userlocation,我在地图视图中有多个注释,在3个不同的数组中列出。 我已经使用-(MKAnnotationView*)mapView:(MKMapView*)mapviewforannotation:(id)annotation方法更改了注释的标注 奇怪的是,我的用户位置正在变成一个定制的注释。 为什么会这样?问题是什么 我如何列出我的注释: myAnn = [[Annotations alloc]init]; location.latitude = 52.338847; location.longitude

我在
地图视图中有多个注释,在3个不同的数组中列出。
我已经使用
-(MKAnnotationView*)mapView:(MKMapView*)mapviewforannotation:(id)annotation
方法更改了注释的标注

奇怪的是,我的用户位置正在变成一个定制的注释。 为什么会这样?问题是什么

我如何列出我的注释:

myAnn = [[Annotations alloc]init];
location.latitude = 52.338847;
location.longitude = 4.937482;
myAnn.coordinate = location;
myAnn.title = @"Afvalpunt";
myAnn.subtitle = @"Rozenburglaan 1";
[category3 addObject:myAnn];

[self.locationArrays addObject:category3];

self.currentAnnotation = 0;

[self.myMapView addAnnotations:[self.locationArrays objectAtIndex:0]];
如何设置我的方法:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {

    MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"MapAn"];
    if (!annotationView) {
        annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MapAn"];
        annotationView.canShowCallout = YES;

        //Blauw Navigatie Auto...
        UIImageView *carView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Driving"]];
        UIButton *blueView = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44+30)];
        blueView.backgroundColor = [UIColor colorWithRed:0 green:0.5 blue:1 alpha:1];
        carView.frame = CGRectMake(11, 14, carView.image.size.width, carView.image.size.height);
        [blueView addTarget:self action:@selector(carClicked) forControlEvents:UIControlEventTouchUpInside];
        [blueView addSubview:carView];
        annotationView.leftCalloutAccessoryView = blueView;
    } 
    return annotationView;
}
-(MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{
MKAnnotationView*annotationView=[mapView dequeueReusableAnnotationViewWithIdentifier:@“MapAn”];
如果(!annotationView){
annotationView=[[MKPinAnnotationView alloc]initWithAnnotation:annotation重用标识符:@“MapAn”];
annotationView.canShowCallout=是;
//自动导航。。。
UIImageView*carView=[[UIImageView alloc]initWithImage:[UIImageName:@“Driving”];
UIButton*blueView=[[UIButton alloc]initWithFrame:CGRectMake(0,0,44,44+30)];
blueView.backgroundColor=[UIColor colorWithRed:0绿色:0.5蓝色:1阿尔法:1];
carView.frame=CGRectMake(11,14,carView.image.size.width,carView.image.size.height);
[blueView添加目标:自我操作:@selector(carClicked)forControlEvents:UIControlEventTouchUpInside];
[blueView添加子视图:车视图];
annotationView.leftCalloutAccessoryView=blueView;
} 
返回注释视图;
}
试试这段代码

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {

    if (annotation == mapView.userLocation) return nil;
    ...
希望此代码对您有用。

尝试此代码

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation 
{
     if ([annotation isKindOfClass:[MKUserLocation class]] || annotation==mapView.userLocation)
    {
        return nil;//Here you can also customise your pin if you dont want pin then just return nil.
    }
    else
    {
     //your code
    }
}
-(MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释
{
if([annotation isKindOfClass:[MKUserLocation类]]| | annotation==mapView.userLocation)
{
return nil;//如果不需要pin,也可以在这里自定义pin,然后返回nil。
}
其他的
{
//你的代码
}
}

谢谢你的回答!如果你满意我的答案,那么请投票表决我的答案。我知道,还有50秒;)
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation 
{
     if ([annotation isKindOfClass:[MKUserLocation class]] || annotation==mapView.userLocation)
    {
        return nil;//Here you can also customise your pin if you dont want pin then just return nil.
    }
    else
    {
     //your code
    }
}