开发者

iPhone - UITextView with html content?

The UITextView has a method named setContentToHTMLString that displays html inside a UITextView. But this is a private API and probably gets my app rejected by apple.

Is there any way around this to somehow set the content to an htm string without calling this method directly? or any other way to allow html content in a view that is editable开发者_运维技巧 (Keyboard accessible)?


I absolutely loath the Three20 framework. It adds huge bulk to your apps, adds a ton of class categories that you probably don't need, multiplies your compiling time many times on a clean compile, and can cause issues if you accidentally don't set all of the sub-projects settings correctly -- personal horror story, I had an app update in the app store broken on all arm6 devices for 3 weeks after adding Three20 while Apple took their sweet time approving my simple fix.

Anyway, enough bashing on Three20. Here's another option if you want something much more compact that is a simple drop in replacement for UITextView with basic HTML support: http://www.cocoacontrols.com/platforms/ios/controls/bctextview. I don't know if that one supports editing though. This one: http://www.cocoacontrols.com/platforms/ios/controls/egotextview supports rich text editing, but I'm not sure if it's in HTML format. They're both worth a look though to see if you can utilize them for your needs. I would only use Three20 as an absolute last resort, and then still probably wouldn't use it.


The closest thing I know to what you are asking are TTStyledText and TTStyledTextLabel, two classes from the Three20 framework that allows you to treat HTML content. They only support a limited subset of HTML, though, so I don't know if this fit your needs.

If you simply want to display/edit some unformatted text taken from the web, have a look at: +stringWithContentsOfURL:encoding:error:


[UITextView setValue:textString forKey:@"contentToHTMLString"];

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜