如何在 UIWebView/UIScrollView 中显示多个具有不同文件扩展名的文件? [英] How can i display more than one file with different file extension in UIWebView/UIScrollView?

查看:26
本文介绍了如何在 UIWebView/UIScrollView 中显示多个具有不同文件扩展名的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I did google too much to find it but not find what i exactly want. I have file.png, file1.jpg, file2.pdf, file.txt and file.doc and i want to preview this all file in one UIWebView or UIScrollView. Please help me how can i do it? Thanks in advance.

推荐答案

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

For Example image showing through HTML sting , This image in bundle file . The HTML sting load in webview follow this ! as like you need creating html sting with all files and display

 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];

这篇关于如何在 UIWebView/UIScrollView 中显示多个具有不同文件扩展名的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆