找到要取出內容方法:
瀏覽器設置 -> 更多工具 -> 開發者工具 -> 手機模式(左下角 手機按鈕)
點擊手機圖標左邊那個搜索框 -> 而後點擊你要隱藏的控件
選擇到你要選擇到的控件 -> 而後左下角代碼就被選中了.
其中右下角中是這個控件對應的css代碼,在其中添加一行display:none,這時這個選中的控件就被隱藏起來了.可是咱們主要經過javascript去操做這個控件javascript
最後代碼以下:css
// // MainViewController.m // webview // // Created by ??? on 15/11/24. // Copyright © 2015年 ???. All rights reserved. // #import "MainViewController.h" @interface MainViewController ()<UIWebViewDelegate> @property (nonatomic,strong)UIWebView *webView; @end @implementation MainViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self webView]; } - (UIWebView *)webView{ if (!_webView) { NSString *urlStr = @"http://group.haodou.com/topic-327282.html"; self.webView = [[UIWebView alloc] initWithFrame:self.view.bounds]; self.webView.delegate = self; self.webView.backgroundColor = [UIColor redColor]; [self.view addSubview:_webView]; NSURL *url=[NSURL URLWithString:urlStr]; NSURLRequest *request=[[NSURLRequest alloc] initWithURL:url]; [self.webView loadRequest:request]; } return _webView; } - (void)webViewDidFinishLoad:(UIWebView *)webView{ [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByClassName('main_mu_bar')[0].style.display = 'NONE'"]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end
編輯文字方法html