如何将文件内容上传到 UITextView?

发布于 2024-08-25 19:49:47 字数 165 浏览 5 评论 0原文

我有大约二十个 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 技术交流群。

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

发布评论

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

评论(2

给我一枪 2024-09-01 19:49:47

文本文件通常不包含格式化文本。

如果“格式化”指的是“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.

吻泪 2024-09-01 19:49:47

在 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.

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