iPhone - UITextView 与 html 内容?
UITextView
有一个名为 setContentToHTMLString
的方法,用于在 UITextView
中显示 html。 但这是一个私有 API,可能会让我的应用程序被苹果拒绝。
有没有办法解决这个问题,以某种方式将内容设置为 htm 字符串,而不直接调用此方法?或者任何其他方式允许可编辑视图中的 html 内容(键盘可访问)?
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)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我绝对讨厌 Three20 框架。它给您的应用程序增加了巨大的体积,添加了大量您可能不需要的类类别,在干净的编译中使您的编译时间成倍增加,并且如果您不小心没有设置所有子项目,则可能会导致问题设置正确——个人的恐怖故事,在添加 Three20 后,我在应用程序商店中的应用程序更新在所有 ARM6 设备上被破坏了 3 周,而苹果却花了很长时间批准了我的简单修复。
无论如何,对 Three20 的攻击已经够多了。如果您想要更紧凑的东西,这是另一个选择,只需简单地替换具有基本 HTML 支持的 UITextView: http://www.cocoacontrols.com/platforms/ios/controls/bctextview。我不知道那个是否支持编辑。这一个: http://www.cocoacontrols.com/platforms/ios/controls/egotextview< /a> 支持富文本编辑,但我不确定是否是HTML格式。它们都值得一看,看看您是否可以利用它们来满足您的需求。我只会使用 Three20 作为绝对的最后手段,然后仍然可能不会使用它。
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.
我知道与您所问的最接近的是
TTStyledText
和TTStyledTextLabel
,这是 Three20 框架,允许您处理 HTML 内容。不过,它们只支持 HTML 的有限子集,所以我不知道这是否满足您的需求。如果您只是想显示/编辑从网络上获取的一些未格式化的文本,请查看:
+stringWithContentsOfURL:encoding:error:
The closest thing I know to what you are asking are
TTStyledText
andTTStyledTextLabel
, 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"];
[UITextView setValue:textString forKey:@"contentToHTMLString"];