showsUserLocation在iPhone模拟器中返回图钉而不是蓝点 [英] showsUserLocation returns pin instead of blue dot in iPhone simulator

查看:105
本文介绍了showsUserLocation在iPhone模拟器中返回图钉而不是蓝点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的-mapView:viewForAnnotation方法,当我创建注释视图时,该方法会掉线.但是,当我在-viewDidLoad中设置mapView.showsUserLocation = YES;时,我会掉到无限循环上的引脚上(预期-在模拟器中),而不是正常的蓝点.

This is my -mapView:viewForAnnotation method which drops pins when i create annotation views. But when i set mapView.showsUserLocation = YES; in -viewDidLoad, i get a pin dropped on Infinite Loop (expected - in simulator) and not the normal blue dot.

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
     MKAnnotationView *anno = nil;
     //create a pin annotation view
MKPinAnnotationView  *pin=[[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pin"]autorelease];

    [pin setPinColor:MKPinAnnotationColorRed];
    pin.animatesDrop=YES;
    pin.canShowCallout = YES;
    pin.calloutOffset = CGPointMake(-5, 5);
    anno = pin;
    return anno;
}

我怎样才能让它掉针并显示蓝点?

How can i get it to drop pins and show the blue dot as well?

谢谢

推荐答案

确实很容易修复,尽管不确定这是否是正确的方法...

Really simple to fix, although unsure if this is the correct way to do it...

if (annotation == mapView.userLocation){
    return nil; //default to blue dot
}

这篇关于showsUserLocation在iPhone模拟器中返回图钉而不是蓝点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆