iphone编程objective-c:mkannotation Pin问题
我尝试在地图上制作一个带有绿色和按钮的自定义图钉。 但它不起作用。我有一个名为 Placemark 的类,它实现 mkannotation 协议。 这是我的方法,应该显示绿色引脚,但事实并非如此:
- (MKAnnotationView *) map:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorGreen;
annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
return annView;
}
我还想指定我的 MKMapview 称为“map”,它是一个 IBOutlet。
谢谢
i tryed to make a customized pin on the map with green color and with a button.
but it doesnt work. I have a class named Placemark that implement mkannotation protocol.
This is my method that supposed to show a green pin but it doesnt:
- (MKAnnotationView *) map:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorGreen;
annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
return annView;
}
i also want to specified that my MKMapview is called "map" and its an IBOutlet.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
方法名称必须是
mapView:viewForAnnotation:
。地图视图专门针对该名称进行查找。您可以更改内部参数变量名称,但不能更改冒号之前的部分。试试这个:
由于拼写错误,地图视图不会调用您的 viewForAnnotation 方法,并且必须在地图上放置默认的红色图钉。
The method name must be
mapView:viewForAnnotation:
. The map view looks specifically for that name. You can change the internal parameter variable names but not the parts before the colons.Try this:
With that misspelling, the map view doesn't call your viewForAnnotation method and must be putting a default red pin on the map.