Nic*_*ard 1 iphone annotations mapkit mkmapview
我认为使用我自己的自定义图钉进行注释会非常容易.
但我从来没有能够让它工作,我不明白为什么!
我只是使用:
Annotation *anno = [[[Annotation alloc] init] autorelease];
anno.coordinate = ridesMap.userLocation.location.coordinate;
anno.title = @"Current Location";
anno.subtitle = [NSString stringWithFormat:@"%f, %f", anno.coordinate.latitude, anno.coordinate.longitude];
static NSString *defaultPinID = @"LocationIdentifier";
MKPinAnnotationView *pinView = (MKPinAnnotationView *)[ridesMap dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if (pinView == nil){
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:anno reuseIdentifier:defaultPinID] autorelease];
}
pinView.image = [UIImage imageNamed:@"custom_pin.png"];
pinView.opaque = NO;
pinView.canShowCallout = YES;
pinView.draggable = NO;
pinView.annotation = anno;
NSLog(@"Adding current location annotation");
return pinView;
Run Code Online (Sandbox Code Playgroud)
我认为这应该工作,因为UIImage是它想要的,我在我的项目中有custom_pin.png文件.
它从不使用我的图像,只是标准的红色图钉.我在这做错了什么?
来自文档:
MKPinAnnotationView类提供了一个具体的注释视图,该视图显示了一个图钉图标,就像在地图应用程序中找到的一样.
换句话说,MK Pin AnnotationView将忽略图像属性并始终显示图钉.请使用常规MKAnnotationView代替.
| 归档时间: |
|
| 查看次数: |
3413 次 |
| 最近记录: |