目标C - UIWebview只加载网页的某个部分? [英] Objective C - UIWebview to load only a certain part of the webpage?

查看:77
本文介绍了目标C - UIWebview只加载网页的某个部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个UIWebview,是否有,我可以只加载一个网页的正文,而不是整个网页与我的UIWebView(又名不加载页眉和页脚)?这个网站不是我的。但看看这个网站的HTML,我只想加载到
div id =mainContentto / div
通过编写一些目标c或javascript?$ /

谢谢!
Alan

解决方案

使用Web-Kit,您可以解析传入的HTML并执行任何您喜欢的操作您正在阅读的网站的合法权利)



数据加载完成后,您可以轻松地将编辑的HTML推送到WKView。



如果你有一个webView的插座,你可以这样做:(例如iOS中的UIWebView)

  [webView loadHTMLString:htmlString baseURL:nil]; 
[webView setNeedsDisplay];


I am working with a UIWebview, is there anyway I can just load just the body of a webpage instead of the entire webpage with my UIWebView (aka not load the header and footer)? This website is not mine. But looking at the HTML of this site, I only want to load to div id="mainContent" to /div Either by writing some objective c or javascript?

Thanks! Alan

解决方案

With Web-Kit you can parse the incoming HTML and do whatever you like to it (within, legal rights to the site you are reading)

Once the data is loaded in you can then push the edited HTML to the WKView fairly easily.

If you have an outlet to the webView you can do: (For example a UIWebView in iOS)

[webView loadHTMLString:htmlString baseURL:nil];
[webView setNeedsDisplay];

这篇关于目标C - UIWebview只加载网页的某个部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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