在 UIWebView 中加载并格式化 rtf 文件

发布于 2024-09-05 12:57:20 字数 381 浏览 2 评论 0原文

我正在尝试在 UIWebView 中加载 rtf 文件的内容。我成功加载内容,但未格式化。字体太大而且没有任何格式。它显示 rtf 内容的颜色,但不显示字体或大小。 那我现在该怎么办呢。还有其他方法来加载 rtf 并格式化它吗?我按以下方式加载 rtf:

NSString *path = [[NSBundle mainBundle] pathForResource:@"Home" ofType:@"rtf"];
NSURL *url=[NSURL fileURLWithPath:path];
NSURLRequest *req=[NSURLRequest requestWithURL:url];
[menuWeb loadRequest:req];

那么我现在应该做什么?

I am trying to load the contents of a rtf file in the UIWebView. I am successful in loading the contents, but it is unformatted. the fonts are too large and it doesn't have any format. it displays the color of the rtf content, but not the font or size.
So what should i do now. is there any other way to load the rtf and format it? I load the rtf in following way:

NSString *path = [[NSBundle mainBundle] pathForResource:@"Home" ofType:@"rtf"];
NSURL *url=[NSURL fileURLWithPath:path];
NSURLRequest *req=[NSURLRequest requestWithURL:url];
[menuWeb loadRequest:req];

So what should i do now?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

ㄖ落Θ余辉 2024-09-12 12:57:20

请改用 HTML,这是获得所需控件的唯一方法。

Use HTML instead, it's the only way you're going to get the control you want.

夏日落 2024-09-12 12:57:20

http://cutesoft.net/example/editRTF.aspx

此页面是一个所见即所得 HTML 生成器。它生成极其干净的 HTML (*),然后我可以将其保存并插入到我的项目中。然后我可以在 Xcode 中修改此 HTML 文件。一切都非常好!

(*) 如果你正确使用它...在普通视图、HTML 视图和最终视图之间翻转——不要将其导出到第二个文本框,否则所有内容都会以难以理解的方式出现。

http://cutesoft.net/example/editRTF.aspx

This page is a WYSIWYG HTML generator. It generates extremely clean HTML (*), which I can then save and insert in my project. I can then modify this HTML file from within Xcode. All very nice!

(*) provided you use it right... flip between the normal view, HTML view and final view -- don't make it export into the second text box otherwise everything comes out in an impenetrable chunk.

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