How can i display more than one file with differen

2019-09-04 09:38发布

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条回答
做个烂人
2楼-- · 2019-09-04 10:25

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];
查看更多
登录 后发表回答