如何将文件内容上传到 UITextView?
我有大约二十个 UITextView 和相应的 .txt 文件。我想要的是让每个 UITextView 获取相应文件的内容并显示它。 此外,文本已格式化并包含一些公式(从 Grapher 复制/粘贴)。我听说过在 UIWebView 中显示格式化文本,但我没有在任何地方找到明确的解释。
提前致谢!
I have about twenty UITextViews and corresponding .txt files. What I want is to make each UITextView take the contents of the corresponding file and display it.
Moreover, the text is formatted and it contains some formulas (copy/pasted from Grapher). I've heard about displaying formatted text in UIWebView, but I haven't found a clear explanation anywhere.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
文本文件通常不包含格式化文本。
如果“格式化”指的是“html”,那么是的,您将需要使用 UIWebView。基本上,您会将文本转换为 HTML 文档,然后使用 Web 视图显示该文档。 Apple 提供了几个示例项目,向您展示如何使用 UIWebView。
Text files normally don't contain formatted text.
If by "formatted" you mean "html" then yes, you will want to use UIWebView. Basically you will convert the text to an HTML document, and then use the web view to display that document. There are several example projects available from Apple that show you how to use UIWebView.
在 UITextView 中显示公式会很困难,因为公式的字符规则与语言文本完全不同。您可以生成 HTML 来显示它,但这也很困难。
我认为最好的选择是将公式绘制到图像上,然后显示图像。这是处理公式显示的传统方式。
Displaying formula in a UITextView will be difficult as the character rules for formula are completely different from language text. You could generate HTML to display it that but that is difficult as well.
I think your best bet would be to draw the formula to an image and then display the image. That is the traditional way to handle the display of formula.