繁体   English   中英

如何使用Objective-C在标注视图的字幕中添加超链接

[英]How to add hyperlink in subtitle on callout view using objective-c

在我的iPhone应用程序中,我需要在标注视图上的字幕中显示指向网站的超链接。 我正在使用displaymap类网址, 有人可以指出此代码中的漏洞吗?

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

西瓦·M(Siva M)

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

- (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;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM