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 ;)
精彩评论