加载网页视图时遇到问题。标题部分有两个本地存储的图像。
并且客户端网址提供了正文内容和背景图片。 1)标题部分应滚动。 2)使用基本URL获取本地图像的路径,因为在baseURL中我们给客户端URL获取身体背景图像。
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"]];
问题是什么?如何在不参考baseURL的情况下获取本地图像路径。
请帮助我,我们将不胜感激。
谢谢你, Madan Mohan。
答案 0 :(得分:5)
您可以将base64编码的图像插入
<img src="data:image/png;base64,SJGFSDGBDFSBGSDFGRKYG2Y32YTHWEGIDSF==" alt="" />
要转换图片,请尝试为您创建img标记的http://www.abluestar.com/utilities/encode_base64/index.php。
答案 1 :(得分:0)