标签:
webViewDidFinishLoad:
stringByEvaluatingJavaScriptFromString
方法NSURL *url = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"html"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [self.webView loadRequest:request];
NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [self.webView loadRequest:request];
// 网页视图加载完毕会调用代理的这个方法 - (void)webViewDidFinishLoad:(UIWebView *)webView { NSString *str = @"document.getElementsByClassName(‘detail_btns2‘)[0].remove();"; [webView stringByEvaluatingJavaScriptFromString:str]; }
- (void)webViewDidFinishLoad:(UIWebView *)webView { NSString *headerStr = @"document.getElementsByTagName(‘h1‘)[0].innerText = ‘测试文字‘;"; [webView stringByEvaluatingJavaScriptFromString:headerStr]; NSString *downLoadStr = @"document.getElementById(‘xiazaiapp‘).getElementsByTagName(‘a‘)[0].innerText = ‘下个鸡蛋‘;"; [webView stringByEvaluatingJavaScriptFromString:downLoadStr]; }
https://github.com/CoderJackyHuang/TextVeiw-Label-HTML-DEMO UITextView和UILabel如何加载HTML内容
https://github.com/CoderJackyHuang/WebViewImgAutoFit WebView加载HTML中的图片时,处理图片超过屏幕的问题,让图片自适应屏幕
https://github.com/CoderJackyHuang/WebViewJavascriptBridgeDemo
另外附赠一个链接,直接带有效果图的。
【iOS和HTML 5交互】iOS中加载html5调用html方法和修改html5内容
标签:
原文地址:http://www.cnblogs.com/xjf125/p/5360288.html