我有一个Xcode工程UIWebView
。 现在,我需要从文件目录中的图像加载到该网页视图。 我怎样才能达致这?
Answer 1:
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];
文章来源: Load document directory image into web view [closed]