开发者

calloutAccestoryControlTapped method won't be used

开发者 https://www.devze.com 2022-12-24 13:57 出处:网络
I have a problem using the -(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccesoryControlTapped:(UIControl *)control method. I tried many ways to test it but it jus

I have a problem using the -(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccesoryControlTapped:(UIControl *)control method. I tried many ways to test it but it just won't appear. Can anyone find a mistake

-(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 s开发者_C百科etPinColor: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];
}


Make sure you implemented the

MKMapViewDelegate protocol

in the parent ViewController.

0

精彩评论

暂无评论...
验证码 换一张
取 消