gpt4 book ai didi

iphone - showUserLocation 在 iPhone 模拟器中返回图钉而不是蓝点

转载 作者:行者123 更新时间:2023-12-03 19:02:51 26 4
gpt4 key购买 nike

这是我的 -mapView:viewForAnnotation 方法,当我创建注释 View 时,该方法会丢弃图钉。但是当我在 -viewDidLoad 中设置 mapView.showsUserLocation = YES; 时,我在无限循环中看到了一个大头针掉落的情况(预期 - 在模拟器中),而不是正常的蓝点。

- (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;
}

我怎样才能让它放下别针并显示蓝点?

谢谢

最佳答案

修复起来非常简单,尽管不确定这是否是正确的方法......

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

关于iphone - showUserLocation 在 iPhone 模拟器中返回图钉而不是蓝点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1853144/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com