简体   繁体   English

Objective-C中的MKA注释图像属性问题

[英]Problem with MKAnnotation image property in Objective-C

I am implementing a MKMapView based application. 我正在实现一个基于MKMapView的应用程序。 In that I am using a custom image instead of displaying a pin by using MKAnnotationView.Image property. 在这种情况下,我使用自定义图像,而不是通过使用MKAnnotationView.Image属性来显示图钉。

It is working fine. 一切正常。 But I had a problem with pin display it is showing in the ocean. 但是我在海洋中显示的别针显示有问题。 When I used default pin it works fine. 当我使用默认针时,它可以正常工作。 I don't know what is the problem. 我不知道是什么问题。

cityAnnotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"CityAnnotation"] autorelease]; 
//cityAnnotationView.image = [[UIImage imageNamed:@"city_pin.png"] stretchableImageWithLeftCapWidth:100 topCapHeight:10]; 
cityAnnotationView.image = [UIImage imageNamed:@"city_pin.png"];
cityAnnotationView.backgroundColor=[UIColor clearColor]; 
cityAnnotationView.annotation = annotation;
cityAnnotationView.canShowCallout = NO; 
cityAnnotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

You need to also set the annotation location. 您还需要设置注释位置。 The default (0,0) location is indeed in the ocean ;) 默认(0,0)的位置确实在海洋中;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM