如何使用objective-c在标注视图上添加字幕中的超链接

时间:2012-05-09 10:28:13

标签: iphone objective-c

在我的iPhone应用程序中,我需要在标注视图中显示字幕的超链接。 我使用的是displaymap类,网址为Can someone point me to a leak in this code?

我需要在subtitle.help me中添加超链接

通过 西瓦M

1 个答案:

答案 0 :(得分:1)

我认为你可以通过这种方式满足你的要求..

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{

    MKPinAnnotationView *locationView;

    locationView=[[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"] autorelease];

    locationView.pinColor=MKPinAnnotationColorPurple;
    locationView.animatesDrop=TRUE;
    locationView.canShowCallout =YES;
    locationView.annotation=annotation;
    locationView.calloutOffset = CGPointMake(-5, 5);
    UITextView *text=[[UITextView alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
    text.dataDetectorTypes=UIDataDetectorTypeLink ;
    text.backgroundColor=[UIColor clearColor];
    text.editable=NO;
    text.text=@"http://google.com";
    locationView.rightCalloutAccessoryView = text;
    return locationView;
}