UITextView or UIWebView with normal words looking

2019-07-27 12:41发布

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.

alt text alt text

3条回答
一夜七次
2楼-- · 2019-07-27 12:54

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.

查看更多
爷的心禁止访问
3楼-- · 2019-07-27 12:55

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

查看更多
beautiful°
4楼-- · 2019-07-27 13:00

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.

查看更多
登录 后发表回答