Load document directory image into web view [closed]

丶灬走出姿态 提交于 2019-12-21 20:32:56

问题


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?


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


来源:https://stackoverflow.com/questions/12367212/load-document-directory-image-into-web-view

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