问题
I was looking at the Twitter for iPhone app and was puzzled.
First of all, there are normal words looking like links inside.
Second, when I touch those link-like words, the text view (or maybe web view) jumps to the corresponding part below (yes, it doesn't open Safari, it just jumps to the text within that text/web view)
Now I want to implement the same effects.
- I should base my implementation on what? UITextView or UIWebView?
- How to make normal words look like links?
- How to make those smooth jumps within such a text/web views?
Thanks in advance.


回答1:
Have you considered the three20 library? In one of its demos, TTCatalog
, there are samples of displaying exactly what you're looking for. What's great about the project is that you can use HTML to do the styling -- it'll know to convert an anchor, for example, into a clickable button.
回答2:
Include a local .html
file in your project
For example :
<html>
<head>
<body>
<p>By tapping "Sign up" above, you are agreeing to the
<a id="T-O-S-link" href="#TOS">Terms of Service</a> and <a id="P-P-link" href="#PP">Privacy Policy</a></p>
</body>
</head>
</html>
Finally display it in a UIWebView
回答3:
You can use a HTML file with anchor tags in it. Add it in Resources folder as .htm and load it on webview. When you click on those links it will go the corresponding linked part within the page.
来源:https://stackoverflow.com/questions/4567953/uitextview-or-uiwebview-with-normal-words-looking-like-links