我做谷歌太多找不到但却找不到我想要的东西。
我有file.png,file1.jpg,file2.pdf,file.txt和file.doc,我想在一个文件中预览这个文件
UIWebView
或UIScrollView
。
请帮帮我怎么办?
提前谢谢。
答案 0 :(得分:0)
对于通过HTML sting显示的示例图像,此图像在捆绑文件中。 webview中的HTML sting加载遵循此行为!就像你需要用所有文件创建html sting并显示
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];