- (void)loadRequest:(NSURLRequest *)request;
- (void)loadHTMLString:(NSString *)string baseURL:(nullable NSURL *)baseURL;
- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)textEncodingName baseURL:(NSURL *)baseURL;
- (void)goBack;
- (void)goForward;
@property (nonatomic, readonly, getter=canGoBack) BOOL canGoBack;
@property (nonatomic, readonly, getter=canGoForward) BOOL canGoForward;
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
if([error code] == NSURLErrorCancelled)
{
return;
}
}
[WebV loadRequest:[NSURLRequest requestWithURL:url]];
-(void)webViewDidFinishLoad:(UIWebView *)webView{
NSString* htmlStr = [WebView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('html')[0].innerHTML"];
}
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSString * url = request.URL.absoluteString ;
return YES;
}
[contentStr appendString:@"<html>"];
[contentStr appendString:@"<head>"];
[contentStr appendString:@"<meta charset=\"utf-8\">"];
[contentStr appendString:@"<meta id=\"viewport\" name=\"viewport\" content=\"width=self.view.frame.size.width,initial-scale=1.0,maximum-scale=5.0,user-scalable=yes\" />"];
[contentStr appendString:@"<meta name=\"apple-mobile-web-app-capable\" content=\"yes\" />"];
[contentStr appendString:@"<meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black\" />"];
[contentStr appendString:@"<meta name=\"black\" name=\"apple-mobile-web-app-status-bar-style\" />"];
[contentStr appendString:@"<style>iframe{width:100%;}</style>"];
[contentStr appendString:@"<style>img{width:100%;}</style>"];
[contentStr appendString:@"<style>table{width:100%;}</style>"];
[contentStr appendString:@"<title>webview</title>"];
NSString * htmlcontent = [NSString stringWithFormat:@"<div id=\"webview_content_wrapper\">%@</div>", contentStr];
[WebV loadHTMLString:htmlcontent baseURL:nil];
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
NSString *jsString = [[NSString alloc] initWithFormat:@"document.body.style.fontSize=%f",20.];
[WebV stringByEvaluatingJavaScriptFromString:jsString];
CGFloat webH = [[WebV stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"] floatValue];
WebV.frame = CGRectMake(0, 91, __zWidth, webH);
CGSize frame = [WebV sizeThatFits:WebV.frame.size];
NSString * height_str= [webView stringByEvaluatingJavaScriptFromString: @"document.getElementById('webview_content_wrapper').offsetHeight + parseInt(window.getComputedStyle(document.getElementsByTagName('body')[0]).getPropertyValue('margin-top')) + parseInt(window.getComputedStyle(document.getElementsByTagName('body')[0]).getPropertyValue('margin-bottom'))"];
float height = [height_str floatValue];
height = height * frame.height / webH;
WebV.frame = CGRectMake(0, 91, __zWidth, height);
contentV.contentSize = CGSizeMake(0, 91+ height);
}