我有一个问题使用 - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccesoryControlTapped:(UIControl *)控制方法。我尝试了很多方法来测试它,但它不会出现。任何人都可以发现错误
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)anno{
MKPinAnnotationView *retval=nil;
if(retval ==nil){
retval=[[[MKPinAnnotationView alloc]initWithAnnotation:anno reuseIdentifier:@"Annotations"]autorelease];
UIButton *disclosure=[UIButton buttonWithType:UIButtonTypeDetailDisclosure];
retval.rightCalloutAccessoryView=disclosure;
[retval setPinColor:MKPinAnnotationColorGreen];
retval.animatesDrop=YES;
retval.canShowCallout=YES;
}
return retval;
}
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccesoryControlTapped:(UIControl *)control{
NSLog(@"Tap");
PhotoDetail *detail=[[PhotoDetail alloc]initWithNibName:@"PhotoDetail" bundle:nil];
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:detail];
[self presentModalViewController:nav animated:YES];
}
答案 0 :(得分:0)
确保您已实施
MKMapViewDelegate protocol
在父ViewController中。