如何将我自己的对象放置在地图上?

发布于 2024-10-06 15:39:28 字数 110 浏览 0 评论 0原文

我正在学习 iphopne 中的地图,我已阅读教程并成功将图钉添加到特定位置....

如何在图钉位置显示我自己的图片?

如果可能的话请提供一些代码...

谢谢

I am learning maps in iphopne i have read a tutorial and successfully added a pin to a specific location ....

How do I show my own picture at the place of the pin?

Please provide some code if possible...

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寒尘 2024-10-13 15:39:28
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
    MKPinAnnotationView *pinView = nil;
    static NSString *defaultPinID = @"CameraAnnotation";
    pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
    if ( pinView == nil )
        pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
        UIImageView *pinImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 24, 32)];
        UIImage *pinImage = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"pinImage" ofType:@"png"]];
        pinImageView.image = pinImage;
        [pinImage release];         

        [pinView addSubview:pinImageView];
        [pinImageView release];

        pinView.canShowCallout = YES;
        pinView.animatesDrop = YES;

        UIButton* photoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        photoButton.tag = ((PinAnnotationView*)annotation).tag;
        pinView.leftCalloutAccessoryView = photoButton;
        return pinView;
    }
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
    MKPinAnnotationView *pinView = nil;
    static NSString *defaultPinID = @"CameraAnnotation";
    pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
    if ( pinView == nil )
        pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
        UIImageView *pinImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 24, 32)];
        UIImage *pinImage = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"pinImage" ofType:@"png"]];
        pinImageView.image = pinImage;
        [pinImage release];         

        [pinView addSubview:pinImageView];
        [pinImageView release];

        pinView.canShowCallout = YES;
        pinView.animatesDrop = YES;

        UIButton* photoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        photoButton.tag = ((PinAnnotationView*)annotation).tag;
        pinView.leftCalloutAccessoryView = photoButton;
        return pinView;
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文