美文网首页
webView加载html

webView加载html

作者: seven_less | 来源:发表于2017-10-28 16:10 被阅读0次
_webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, HEIGHT(1))];
           self.tableView.tableFooterView = _webView;
        _webView.delegate = self;
        [_webView setUserInteractionEnabled:NO];
        _webView.scrollView.bounces = NO;
        _webView.scrollView.scrollEnabled = NO;
        NSString *htmls = [NSString stringWithFormat:@"<html> \n"
                           "<head> \n"
                           "<style type=\"text/css\"> \n"
                           "body {font-size:15px;}\n"
                           "</style> \n"
                           "</head> \n"
                           "<body>"
                           "<script type='text/javascript'>"
                           "window.onload = function(){\n"
                           "var $img = document.getElementsByTagName('img');\n"
                           "for(var p in  $img){\n"
                           " $img[p].style.width = '100%%';\n"
                           "$img[p].style.height ='auto'\n"
                           "}\n"
                           "}"
                           "</script>%@"
                           "</body>"
                           "</html>",response[@"data"][@"intro"]];
        [_webView loadHTMLString:htmls baseURL:nil];

//代理方法

  • (void)webViewDidFinishLoad:(UIWebView *)theWebView
    {
    if ([[theWebView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"] floatValue] != 0) {
    webViewHeight = [[theWebView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"] floatValue];
    CGRect newFrame = _webView.frame;
    newFrame.size.height = webViewHeight;
    _webView.frame = newFrame;
    [self.tableView setTableFooterView:theWebView];
    }
    }

相关文章

  • swift使用webView加载html

    format好html字符串 加载html webViewDidFinishLoad()方法webView加载完调...

  • WebView 与JS 互相调用

    WebView加载本地html loadUrl("file:///android_asset/html/index...

  • 2020-08-21

    Webview (1)加载URL(网络或者本地assets文件夹下的html文件)(2)加载html代码(3) ...

  • iOS WebView加载本地js、css文件

    iOS WebView加载本地js、css文件 思路:对html进行操作,然后webView loadHtml 将...

  • Android-WebView使用

    开发中使用WebView加载url、html标签必不可少,比如广告、活动界面通过WebView加载具有实效性。下面...

  • H5与Android互调

    1. WebView加载页面 webview可以加载本地和网络页面,根据html的文件位置,有不同的写法. mWe...

  • Android webview和H5交互

    1. WebView加载页面 webview可以加载本地和网络页面,根据html的文件位置,有不同的写法. 通常情...

  • Android开发-WebView

    WebView 加载网页1.加载URL(网络或者本地assets文件下的html文件)2.加载htmL代码3.Na...

  • JS和OC相互传值

    //webView加载html文件NSURL *url = [[NSBundle mainBundle]URLFo...

  • webView加载html

    //代理方法 (void)webViewDidFinishLoad:(UIWebView *)theWebView...

网友评论

      本文标题:webView加载html

      本文链接:https://www.haomeiwen.com/subject/tyjspxtx.html