将文档目录图像加载到Web视图中 [英] Load document directory image into web view
本文介绍了将文档目录图像加载到Web视图中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个UIWebView
的Xcode项目.现在,我需要将图像从文档目录加载到该Web视图.我该如何实现?
I have a an Xcode project with UIWebView
. Now I need to load an image from document directory to that webview. How can I acheive this?
推荐答案
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *imagePath = [documentsDirectory stringByAppendingPathComponent:
[NSString stringWithFormat: @"/imageName.png"]];
[myWebView loadHTMLString:[NSString stringWithFormat:@"<html><body><img src=\"file://%@\"></body></html>",imagePath] baseURL:nil];
这篇关于将文档目录图像加载到Web视图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文