UIWebView Load Project local page with local picture
-(void) viewdidload
{
[Super Viewdidload];
NSString *filepath = [[NSBundle mainbundle]pathforresource:@ "1" oftype:@ "html"];
NSString *htmlstring = [NSString stringwithcontentsoffile:filepath encoding:nsutf8stringencoding Error:nil];
Mywebview = [[UIWebView alloc] initWithFrame:self.view.bounds];
Mywebview.delegate = self;
[Self.view Addsubview:mywebview];
[Mywebview loadhtmlstring:htmlstring Baseurl:[nsurl Urlwithstring:filepath];
}
-(void) Webviewdidfinishload: (UIWebView *) WebView
{
NSString *imagepath = [[NSBundle mainbundle] resourcepath];
ImagePath = [ImagePath stringbyreplacingoccurrencesofstring:@ "/" withstring:@ "//"];
ImagePath = [ImagePath stringbyreplacingoccurrencesofstring:@ "" withstring:@ "%20"];
NSString * js = [nsstring stringwithformat:@ "document.images[0].src= ' file:/%@//%@ '", imagepath,@ "Icon-04.png"];
[Mywebview Stringbyevaluatingjavascriptfromstring:js];
NSString *path = [Mywebview stringbyevaluatingjavascriptfromstring:@ "DOCUMENT.IMAGES[0].SRC"];
NSLog (@ "path:%@", Path);
}
iOS loading local HTML