2011-10-07 91 views
2

我想插入一个超链接,因为我们已经在uiwebview中。由于链接显示为“阅读更多”,当用户点击它时,它必须重定向到iPhone浏览器中的URL(即safari)。如何在UITextView中插入超链接?

请不要建议我使用UIwebview代替它。并不建议我

textView.dataDetectorTypes = UIDataDetectorTypeLink;

因为在第二种方式显示给用户的网址,我不想。

给我任何其他建议,以实现这个或任何示例代码。

回答

0

是否必须是textView?我做了一些类似的文字添加按钮,背景不可见,并添加动作来点击Safari浏览器,如下所示:

UIButton *hiperlinkButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [hiperlinkButton setTitle:@"your text" forState:UIControlStateNormal]; 
    [hiperlinkButton setTitleColor:[UIColor colorWithRed:204.0/255.0 green:33.0/255.0 blue:0.0/255.0 alpha:1.0] forState:UIControlStateNormal]; 
    [hiperlinkButton setFrame:CGRectMake(yourposition and size)]; 
    [hiperlinkButton.titleLabel setFont:[UIFont systemFontOfSize:15]]; 
    [hiperlinkButton addTarget:self action:@selector(callSafari:) forControlEvents:UIControlEventTouchUpInside]; 
    [contactsView insertSubview:hyperlinkButton aboveSubview:contactsView]; 
+0

呃..什么是contactOrkut?不应该是hiperlinkbutton?为什么这甚至被标记为正确? –

+0

是的,我忘了改名字了...... – flopes