向 UITextView 添加非 Web 链接的最佳方法

发布于 2024-08-04 04:48:15 字数 228 浏览 2 评论 0原文

我正在创建一个字典样式的应用程序,它呈现一个充满单词的表格视图,当选择一个单词时,会显示一个 UITextView 来显示该单词的定义。我想做的是添加一行“另请参阅:synonym1、synonym2”,其中 synonym1 和 synonym2 是将用户带到所触及的同义词的定义的链接。

添加这些动态链接的最佳方式是什么?按钮?以某种方式动态添加一个小的 UIWebView 和 UItable ?

谢谢!

I am creating a dictionary-style app that presents a tableview full of words, and when a word is selected, a UITextView is displayed that shows the definition of the word. What I would like to do is add a line that says "See also: synonym1, synonym2" where synonym1 and synonym2 are links that will take the user to the definition for the synonym that is touched.

What is the best way to add these dynamic links? Buttons? Somehow add a small UIWebView a UItable on the fly?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

镜花水月 2024-08-11 04:48:15

我将用 UIWebView 替换您的 UITextView 并使用包含您的描述文本和链接的内容。为类似的事情动态生成 HTML 是相当简单的。

您可以为您的应用程序注册自定义 URL 方案,或者您可以 拦截被点击的链接

如果您的链接始终组合在一起,那么您没有理由不能在自定义视图中使用一堆 UIButton,但您必须自己处理布局和换行。使用 HTML 似乎更容易。

I would replace your UITextView with a UIWebView and use that contain your description text and your links. It's fairly trivial to generate HTML on the fly for something like that.

You could register a custom URL scheme for your app, or you could intercept links as they're clicked.

If your links are always grouped together there's no reason why you couldn't use a bunch of UIButtons inside a custom view, but then you'd have to handle layout and wrapping on your own. It seems a lot easier to do it in HTML.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文