6 iphone map mkmapview mkannotation ios
在我的MKMap视图中,我使用图像自定义了注释引脚.但是仍然有些引脚是静态的并且没有显示给定的图像.
我正在使用 - (MKAnnotationView*)mapView:(MKMapView*)mapView viewForAnnotation:(id)注释来设置图钉图像.
在这里添加我的代码和屏幕:
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView* pinView = [[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
pinView.animatesDrop=YES;
pinView.canShowCallout=YES;
pinView.pinColor= MKPinAnnotationColorGreen;
pinView.enabled = YES;
pinView.canShowCallout = YES;
pinView.image=[UIImage imageNamed:@"bublerest.png"]; //here I am giving the image
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView = rightButton;
UIImageView *profileIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rest_image2.png"]];
pinView.leftCalloutAccessoryView = profileIconView;
return pinView;
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
归档时间: |
|
查看次数: |
11449 次 |
最近记录: |