ios中Mkmapview中的自定义标注

Posted

技术标签:

【中文标题】ios中Mkmapview中的自定义标注【英文标题】:custom callout in Mkmapview in ios 【发布时间】:2013-04-05 10:30:42 【问题描述】:

我必须在 ios 中的注释点击上显示自定义视图,我必须在自定义视图中显示 7 个图像、名称和详细信息披露按钮。单击详细信息披露按钮时,我必须调用新的视图控制器。我该怎么做?

【问题讨论】:

阅读我的答案***.com/questions/15684080/… 【参考方案1】:
  -(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

【讨论】:

以上是关于ios中Mkmapview中的自定义标注的主要内容,如果未能解决你的问题,请参考以下文章