webView的高度自適應

- (void)webViewDidFinishLoad:(UIWebView *)webView

{

//    text center

    NSString *bodyStyle = @"document.getElementsByTagName('body')[0].style.textAlign = 'center';";

    [webView stringByEvaluatingJavaScriptFromString:bodyStyle];

    //webview自適應高度

    CGRect frame = webView.frame;

    frame.size.width = SCREEN_SIZE.width-36;

    frame.size.height = 1;

    webView.scrollView.scrollEnabled = NO;

    webView.frame = frame;

    frame.size.height = webView.scrollView.contentSize.height;

    webView.frame = frame;

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章