在 UIWebView 中加载并格式化 rtf 文件
我正在尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请改用 HTML,这是获得所需控件的唯一方法。
Use HTML instead, it's the only way you're going to get the control you want.
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.