【问题标题】:How to add hyperlink in subtitle on callout view using objective-c如何使用objective-c在标注视图的字幕中添加超链接
【发布时间】:2012-05-09 10:28:13
【问题描述】:

在我的 iPhone 应用程序中,我需要在标注视图的副标题中显示指向网站的超链接。 我使用的显示地图类 url 是 Can someone point me to a leak in this code?

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

通过 湿婆M

【问题讨论】:

    标签: iphone objective-c


    【解决方案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;
    }
    

    【讨论】:

    • 是的,我的要求是这样的,但是我们已经使用 rightCalloutAccessoryView 和 leftCalloutAccessoryView 来添加图像,我需要在字幕中添加超链接
    • 您可以将 UIView 设置为 rightCalloutAccessoryView 或 leftCalloutAccessoryView。在那个 UIView 中你可以同时添加图片和 TextView。
    • 是否可以在字幕中添加超链接?
    猜你喜欢
    • 2011-08-29
    • 1970-01-01
    • 1970-01-01
    • 2019-09-17
    • 2014-12-03
    • 1970-01-01
    • 2020-02-07
    • 2017-08-06
    • 2023-02-06
    相关资源
    最近更新 更多