0
我必須在ios上顯示註釋中的自定義視圖,我必須在自定義視圖中顯示7個圖像,名稱和詳細信息顯示按鈕。點擊詳細信息披露按鈕,我必須調用新的視圖控制器。我應該怎麼做?ios中的Mkmapview中的自定義標註
我必須在ios上顯示註釋中的自定義視圖,我必須在自定義視圖中顯示7個圖像,名稱和詳細信息顯示按鈕。點擊詳細信息披露按鈕,我必須調用新的視圖控制器。我應該怎麼做?ios中的Mkmapview中的自定義標註
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
// Define your reuse identifier.
MKPinAnnotationView *annotationView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annotationView.pinColor = MKPinAnnotationColorGreen;
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
// Adding Button on annotation callout which is your detail disclosure button//
UIButton *rightButton = [[UIButton alloc]initWithFrame:CGRectMake(0.0f,0.0f,28.0f,22.0f)];
[rightButton setImage:[UIImage imageNamed:@"rightArrow.png"] forState:UIControlStateNormal];
[rightButton addTarget:self
action:@selector(pressDetailBtn:)
forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
annotationView.image=[UIImage imageNamed:@"orangePin.png"];
annotationView.opaque = NO;
return annotationView;
}
-(void)pressDetailBtn:(id)sender
{
YourVC code here
}
閱讀我的回答http://stackoverflow.com/questions/15684080/using-a-custom-annotation-when-adding-it-to-map/15684322#15684322 – iPatel 2013-04-05 10:50:29