【发布时间】:2013-04-05 10:30:42
【问题描述】:
我必须在 ios 中的注释点击上显示自定义视图,我必须在自定义视图中显示 7 个图像、名称和详细信息披露按钮。单击详细信息披露按钮时,我必须调用新的视图控制器。我该怎么做?
【问题讨论】:
我必须在 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
}
【讨论】: