showUserLocation 在 iPhone 模拟器中返回图钉而不是蓝点
这是我的 -mapView:viewForAnnotation
方法,当我创建注释视图时,该方法会丢弃图钉。但是当我在 -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;
}
我怎样才能让它放下别针并显示蓝点?
谢谢
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?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
修复起来非常简单,尽管不确定这是否是正确的方法......
Really simple to fix, although unsure if this is the correct way to do it...
与其他答案类似,这里有一些接近的内容:
当然,使用这样的东西需要您自担风险。如果苹果决定更改该名称,它可能会在明天停止工作。
Similar to the other answer, here's something close:
Of course, use something like this at your own risk. It could stop working tomorrow if Apple decided to change that name.
通常,您使用自己的注释类来查找与注释相关的信息。在这种情况下,要仅处理您自己的注释,请使用类似
Often you use your own class of annotation to look up information related to the annotation. In that case, to only handle your own annotations, use something like