Without using baseURL, you can add local images to UIWebView

I had a problem loading webview. Part of the header has two images that are stored locally.

and body content and inverse images are specified by the client. 1) Scroll part of the title. 2) Get the path for local images without using the base url, because in baseURL we provide the client URL to get background images of the body.

NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; NSString *absStirng=[[[NSBundle mainBundle] resourceURL] absoluteString]; printf("\n absStirng=============================== %s",[absStirng UTF8String]); NSString* appendString=@ ""; appendString = [appendString stringByAppendingString:@"<body>"]; appendString =[appendString stringByAppendingString:@"<table background="]; appendString =[appendString stringByAppendingString:absStirng]; appendString =[appendString stringByAppendingString:@"myimage.png width='320' height='45' style='background-repeat:no-repeat'>"]; // here unable to get local image with full path as given. appendString =[appendString stringByAppendingString:@"<tr>"]; appendString =[appendString stringByAppendingString:@"<td align='left' width='57' height='31' style='padding: 6px 0 0 0' ><a href='/map/'><img src="]; appendString =[appendString stringByAppendingString:absStirng];// here unable to get local image with full path as given.v appendString =[appendString stringByAppendingString:@"backButton.png></a></td>"]; appendString =[appendString stringByAppendingString:@"<td align='left' valign='middle' style='padding: 0 0 0 65px; font-family:Helvetica; font-size:21px ; font-weight:bold ; color:#FFF'>Details</td>"]; appendString =[appendString stringByAppendingString:@"</tr>"]; appendString =[appendString stringByAppendingString:@"</table>"]; returnString = [returnString stringByReplacingOccurrencesOfString:@"<body>" withString:appendString]; [webView loadHTMLString:returnString baseURL:[NSURL URLWithString:@"http://client url given here"]]; 

What is the problem? how to get the local image path without reference to baseURL.

Please help me and any help would be appreciated.

Thank you Madan Mohan.

+2
source share
2 answers

You can insert base64 encoded images as

 <img src="data:image/png;base64,SJGFSDGBDFSBGSDFGRKYG2Y32YTHWEGIDSF==" alt="" /> 

To convert the image, try http://www.abluestar.com/utilities/encode_base64/index.php , which will create an img tag for you.

+5
source
  • You can use the full URL for deleted images;
  • You can embed local base64 encoded images in HTML.
0
source

Source: https://habr.com/ru/post/1412633/


All Articles