How can i display more than one file with different file extension in UIWebView/UIScrollView?

梦想的初衷 提交于 2019-12-12 04:53:04

问题


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.


回答1:


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`

Once Check this

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


来源:https://stackoverflow.com/questions/26794357/how-can-i-display-more-than-one-file-with-different-file-extension-in-uiwebview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!