UIWebView加载的html里,加载工程文件的图片
第一种方法:
可以参照http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html。
第二种方法:
这个html是你自己写的一个本地html文件,用来布置UIWebView界面。里面用到的图片可以是工程文件里面的,也可以是网络上的。给出Url。
解决在UIWebView中加载图片时出现延迟现象的做法
文字和图片同时显示:NSString* showHtml = @"<html><head></head><body><img src='https://img-blog.csdnimg.cn/2022010914465968472.jpg'/><p>here is show a picture.</p></body></html>"; NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"www.abc.com/img/img1.jpg"]]; NSString* imageString = [imageData base64Encoding]; UIWebView* webView = [UIWebView alloc]; [webView loadHTMLString:[NSString stringWithFormat:showHtml, imageString] baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]]; //以下把该UIWebView显示出来的代码略
粗体的地方就是通过base64来实现的地方,我们这里显示的是jpg格式的图片,因此在img标签的src属性里面写的是“src=’data:image/jpg;base64,%@’”,而如果是其他格式的图片的话记得把对应的地方给改一下
用Javascript判断图片是否存在,不存在则显示默认图片
<img src=" http://www.iecn.net/images/logo_home.gif" http://www.cnlei.org/BLOG/styles/style2007/images/logo.gif'" />1 当拖动超过边界,不想让其弹跳
html里面加上
2 想弹出Acti*****heet,加上
[font=] html里面加上