如何模拟富文本视图?

发布于 2024-10-10 05:08:17 字数 896 浏览 0 评论 0原文

我想模拟这种富文本视图:(来自 iPad 版 twitter)alt text 仅带有链接按钮的文本。 ;) 如何在链接上放置按钮?或者让链接看起来像这样酷?

我想要这种视图,但即使视图未处于编辑模式,我也必须能够选择文本(这在 Twitter 应用程序中是不可能的),但在编辑它时,它不必那么花哨。一个简单的 UITextView 应该足够了。

我有什么想法可以实现这一点,或者有没有我可以使用的库?

我不想使用 UIWebView 因为我想要至少 9 个这样的视图,也许 UIWebView 很慢?

谢谢

编辑

在早期版本(iOS2.x)中,UITextView中有一个未记录的API:

[myTextView setContentToHTMLString:@"<body><strong><p>Content In HTML</p></strong><p>Other Paragraph</p></body>"];

在iOS4.2中仍然有效! (模拟器测试)。但我的应用程序可能会被拒绝;(

我还发现这篇文章支持 UITextView 仍然支持 HTML 但 API 不公开的理论: http://www.lazyrobot。 org.uk/2010/06/rich-text-on-iphone.html#comment-form

I want to simulate this kind of rich text view: (From twitter for iPad)alt text
Only the text with the button on the link. ;) How can I place a button on the link? or make the link look as cool as this?

I would like to have this kind of view but I have to be able to select text even id the view is not in editing mode (this is not possible in Twitter app), but when editing it it does not have to be that fancy. A simple UITextView should be enough.

Any ideas how can I achieve this or is there a library out there I can use?

I don't want to use UIWebView since I want to have at least 9 of this views and maybe UIWebView is slow?

Thanks

EDIT:

In early versions (iOS2.x) there was a undocumented API in UITextView:

[myTextView setContentToHTMLString:@"<body><strong><p>Content In HTML</p></strong><p>Other Paragraph</p></body>"];

that still works in iOS4.2! (simulator test). But probably my app will be rejected;(

I also have found this article that support the theory that UITextView still supports HTML but the API is not public:
http://www.lazyrobot.org.uk/2010/06/rich-text-on-iphone.html#comment-form

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

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

发布评论

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

评论(4

箜明 2024-10-17 05:08:17

尝试 LRLinkableLabel。
https://github.com/lukeredpath/LRLinkableLabel
它支持链接格式,但不支持更丰富的格式。
尝试过 CoreText 吗?

Try LRLinkableLabel.
https://github.com/lukeredpath/LRLinkableLabel
It supports formatting for links, but not richer formats.
Tried it with CoreText yet?

原野 2024-10-17 05:08:17

您也许可以使用 UIWebView 和自定义 CSS 来做到这一点。

You could probably do it with a UIWebView and custom CSS.

〆一缕阳光ご 2024-10-17 05:08:17

这类似于这个问题: UITextView 或 UIWebView普通单词看起来像链接

这是我提供的答案:

您是否考虑过 Three20 库 ?在其演示之一 TTCatalog 中,有一些示例可以准确显示您要查找的内容。该项目的优点在于您可以使用 HTML 来进行样式设置 - 例如,它会知道将锚点转换为可点击的按钮。

This is similar to this question: UITextView or UIWebView with normal words looking like links

Here's the answer I provided:

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.

青芜 2024-10-17 05:08:17

看看这个开源项目: https://github.com/Cocoanetics/NSAttributedString- Additions-for-HTML

这使您能够从 HTML 生成 NSAttributedStrings,并且 DTAttributedTextCintentView 有一个委托方法来定位链接的按钮。

Have a look at this Open Source project: https://github.com/Cocoanetics/NSAttributedString-Additions-for-HTML

This enables you to generate NSAttributedStrings from HTML and the DTAttributedTextCintentView has a delegate method to position a button for the link.

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