开发者

Problem with MKAnnotation image property in Objective-C

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜