【发布时间】:2015-11-11 22:30:34
【问题描述】:
我正在尝试从我的学校网站制作一个显示教师目录的应用程序。仅使用 uiwebview 并加载网站的问题在于该网站并未针对移动设备进行优化,因此所有额外的标题和侧面板都会显示。我只想要网站的中间特定部分。我找到了 div 和所有内容,但似乎不能只显示网站的中间内容而不是整个网站。
【问题讨论】:
我正在尝试从我的学校网站制作一个显示教师目录的应用程序。仅使用 uiwebview 并加载网站的问题在于该网站并未针对移动设备进行优化,因此所有额外的标题和侧面板都会显示。我只想要网站的中间特定部分。我找到了 div 和所有内容,但似乎不能只显示网站的中间内容而不是整个网站。
【问题讨论】:
获取html内容,然后去掉不需要的标签并传递给webview
NSString *string = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://yourwebsite.com"] encoding:NSASCIIStringEncoding error:nil];
NSLog(@"String is %@",string);
//String will contain the whole tags. Just strip the content in string which you want and pass it to webview
[self.webview loadHTMLString:string baseURL:nil];
【讨论】: