Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load document directory image into web view [closed]

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?

like image 260
user1662494 Avatar asked Nov 30 '25 09:11

user1662494


1 Answers

 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];
like image 86
AppleDelegate Avatar answered Dec 03 '25 00:12

AppleDelegate