iOS WebView>仅显示包含图片的网站的主要内容 [英] iOS WebView > Display only main-content from a website including pictures

查看:390
本文介绍了iOS WebView>仅显示包含图片的网站的主要内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何仅获取网页的主要内容部分并将其显示在UIWEBVIEW中?



您拥有该网站吗?您可能希望创建该网站的替代页面,该页面显示更易于移动的页面版本。如果是博客,或运行像wordpress这样的东西,那么移动模板就有插件。这为使用任何移动设备的任何人提供快速易读的网站版本带来了额外的好处。


How do I fetch just the main-content part of a webpage and display it in an UIWEBVIEW? Link to the page

When I look at the code of the webpage I see that the 'What is new?' posts appear below:

<div id="content-header" class="clearfix">
                  <a name="main-content" id="main-content"></a>
          <h1 class="title">Aktuell</h1>                                      </div> <!-- /#content-header -->

Is it possible to relate to id="main-content within the UIWEBVIEW to display just this part of the website instead of the whole page?

Screenshot shows visually what I like to get.

P.S This is my code to display the whole webpage:

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSString *golfClubURL = @"http://golfplatz-altenstadt.de";

    NSURL *loungeURL = [NSURL URLWithString:golfClubURL];

    NSURLRequest *myrequest = [NSURLRequest requestWithURL:loungeURL];

    [self.webView loadRequest:myrequest];

    self.webView.scalesPageToFit = YES;
}

解决方案

The process to make this work is to load the URL in to a string, and then modify the string, and then send the string to display in the UIWebView.

It will require you to parse the html. You will probably be best off cutting out just what part you want, and adding in a header and footer.

You might want to look at NSURLConnection

Do you own the website? You might want to create an alternative page of the site that shows a more mobile friendly version of the page. If it is a blog, or running something like wordpress there are plug-ins for mobile templates. This has an added benefit of giving a fast easy to read version of the site for anyone using any mobile device.

这篇关于iOS WebView&gt;仅显示包含图片的网站的主要内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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