开发者

How to simulate a rich text view?

I want to simulate this kind of rich text view: (From twitter for iPad)

How to simulate a rich text view?

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


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


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜