开发者

Problem with MKAnnotation image property in Objective-C

开发者 https://www.devze.com 2023-01-22 18:44 出处:网络
I am implementing a MKMapView based application. In that I am using a custom image instead of displaying a pin by using MKAnnotationView.Image property.

I am implementing a MKMapView based application. In that I am using a custom image instead of displaying a pin by using MKAnnotationView.Image property.

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"];
cityAnno开发者_如何学编程tationView.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

精彩评论

暂无评论...
验证码 换一张
取 消