【问题标题】:How can i display more than one file with different file extension in UIWebView/UIScrollView?如何在 UIWebView/UIScrollView 中显示多个具有不同文件扩展名的文件?
【发布时间】:2015-01-03 20:07:09
【问题描述】:

我在谷歌上搜索了太多东西,但没有找到我真正想要的东西。 我有 file.png、file1.jpg、file2.pdf、file.txt 和 file.doc,我想在一个文件中预览所有文件 UIWebViewUIScrollView。 请帮帮我我该怎么做? 提前致谢。

【问题讨论】:

  • 试试QLPriview控制器
  • 其他明智的在 HTML(字符串)页面上创建,包括 UIWebView 中加载的所有文件
  • 你有示例代码吗?仅供参考:我还需要总页数。
  • 例如通过 HTML 字符串显示的图像,此图像在捆绑文件中。 webview NSString *imageFileName = @"images" 中的 HTML sting 加载; NSString *imageFileExtension = @"jpg"; NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageFileName ofType:imageFileExtension]; NSString *imgHTMLTag = [NSString stringWithFormat:@"", imagePath]; [myWebView loadHTMLString:imgHTMLTag baseURL:nil];
  • 这是示例一旦尝试获取任何网页设计师的更多信息,我将更新我的帖子以显示两张图片,一张 pdf 显示(这不是确切的方式)

标签: ios iphone uiwebview uiscrollview


【解决方案1】:

例如通过 HTML 字符串显示的图像,此图像在捆绑文件中。 webview 中的 HTML sting 加载遵循这个!就像您需要使用所有文件创建 html 刺痛并显示

 NSString *imageFileName = @"images";
    NSString *imageFileExtension = @"jpg";
    NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageFileName ofType:imageFileExtension];
    NSString *imgHTMLTag = [NSString stringWithFormat:@"<img src=\"file://%@\" />", imagePath];
    [myWebView loadHTMLString:imgHTMLTag baseURL:nil];`enter code here`

检查一下

 NSString *imageFileName = @"images";
    NSString *imageFileExtension = @"jpg";
    NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageFileName ofType:imageFileExtension];
    NSString *pdfPath = [[NSBundle mainBundle] pathForResource:@"Disciplinary" ofType:@"pdf"];
    NSString *imgHTMLTag = [NSString stringWithFormat:@"<html><body><img src=\"file://%@\" /></body><body><img src=\"file://%@\" /></body><body><img src=\"file://%@\" /></body></html><body><object id =\"PDFObj\" data=\"file://%@\"/ type=\"application/pdf\" width = \"1000\" height = \"10000\"></body>", imagePath,imagePath,pdfPath,pdfPath];
    [img loadHTMLString:imgHTMLTag baseURL:nil];

【讨论】:

  • 我想你不清楚我的要求,我想在单一视图中加载 file.png、file1.jpg、file2.pdf、file.txt 和 file.doc(Webview/scrollview)
  • 是的,只有这一步!您使用上面示例中的所有文件创建 HTML 字符串并加载到 webview
  • 好的看看有什么问题我会帮你的
  • 它只打开一个文档。 :(
  • 总页数的意思
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-13
相关资源
最近更新 更多