簡體   English   中英

在iOS的Mkmapview中自定義標注

[英]custom callout in Mkmapview in ios

我必須在ios中的注解單擊上顯示自定義視圖,我必須在自定義視圖中顯示7張圖像,名稱和詳細信息顯示按鈕。 在單擊詳細信息披露按鈕后,我必須調用新的視圖控制器。 我該怎么辦?

  -(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
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM