#import "ViewController.h"
@interface ViewController ()<UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
[self.view addSubview:self.webView];
self.webView.delegate = self;
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://m.ys137.com/article_803088.html"]];
[self.webView loadRequest:request];
//自适应屏幕大小
self.webView.scalesPageToFit = YES;
}
//UIWebView的代理方法
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
//具体去除广告的操作
//查看更详细的操作进入:http://jwdev.cn/2015/09/28/use-javascript-to-delete-web-element/
[webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByClassName('m-container')[0].style.display = 'none'"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
@interface ViewController ()<UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
[self.view addSubview:self.webView];
self.webView.delegate = self;
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://m.ys137.com/article_803088.html"]];
[self.webView loadRequest:request];
//自适应屏幕大小
self.webView.scalesPageToFit = YES;
}
//UIWebView的代理方法
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
//具体去除广告的操作
//查看更详细的操作进入:http://jwdev.cn/2015/09/28/use-javascript-to-delete-web-element/
[webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByClassName('m-container')[0].style.display = 'none'"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end