如果不使用baseURL,我们可以在UIWebView中添加本地图像 [英] Without using baseURL can we add local Images in the UIWebView

查看:121
本文介绍了如果不使用baseURL,我们可以在UIWebView中添加本地图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

加载网页视图时遇到问题。标题部分有两个图像存储在本地。

I am having a problem when loading a webview. Header part having two images which are stored locally.

和身体内容和背景图像由客户端URL给出。
1)标题部分应滚动。
2)使用基本网址获取本地图像的路径,因为在baseURL中我们提供客户端网址来获取正文背景图像。

and body content and back ground images are given by client url. 1)Header part should be scrolled. 2)Get the path for local images with out using base url because in baseURL we are giving client url to get the body background images.

 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的情况下获取本地图像路径。

What the problem is? how to get the local images path with out reference to baseURL.

请帮助我,任何一个帮助将不胜感激。

Please help me and any one help will be appreciated.

谢谢你,
Madan Mohan。

Thank you, Madan Mohan.

推荐答案

您可以插入base64编码的图像

You may insert base64 encoded images as

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

要转换图像,请尝试 http://www.abluestar.com/utilities/encode_base64/index.php 将为您创建img标记。

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

这篇关于如果不使用baseURL,我们可以在UIWebView中添加本地图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆