問題描述
如何在 iPhone 的 UITextView 中嵌入鏈接 (How to embed a link in a UITextView for the iphone)
I'm wondering if it is possible to put a hyperlink in a UITextView that will open up safari and take the user to a web page. And if so how can I accomplish this.
Thanks in advance for your help.
參考解法
方法 1:
yes, you can by setting the dataDetectorTypes property pf the UITextView to 'UIDataDetectorTypeLink '.
方法 2:
Unfortunately not at the moment since there are no attributes you can attach to the text.
You have a couple of options
1) Use a UIWebView instead.
2) If the text is in a known position then you could overlay a button on the coordinates. This is how Twitterific on the iPhone does links,
方法 3:
You should take a look at the TTStyledText class from Joe Hewitt's Three20 framework.
(by jmurphy、Sunil mathew、NeilInglis、Nathan de Vries)