Search code examples
iphoneiosmkmapviewmkannotation

Can an Annotation Callout subtitle be a link that launches safari?


I want to add as a subtitle in a Callout Bubble of MKAnnotationPoint a link that launches Safari Browser that eventually goes to that link.Is this possible?


Solution

  • Why don't you use a button in the bubble, that's why it is designed for?

    - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
        MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
        annView.pinColor = MKPinAnnotationColorGreen;
        annView.animatesDrop=TRUE;
        annView.canShowCallout = YES;
        annView.calloutOffset = CGPointMake(-5, 5);
    
        annotationButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        [annotationButton addTarget:self action:@selector(annotationAction) forControlEvents:UIControlEventTouchUpInside];
        annView.rightCalloutAccessoryView = annotationButton;
    
    
        return annView;
    }
    - (void) annotationAction {
    //Call a web view here
    }