UITextView or UIWebView with normal words looking like links

蓝咒 提交于 2020-01-24 20:13:27

问题


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.

  1. I should base my implementation on what? UITextView or UIWebView?
  2. How to make normal words look like links?
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!