2017年6月29日
一.web頁面中有視頻,播放后在退出 ,還是有聲音如何解決
1.原理:退出后調(diào)用空地址
2.實現(xiàn)
(void)completBackClick
{
if (self.webView.canGoBack) {
[self.webView goBack];
}else{
[self jsFinishWebView];
}
}(void)jsFinishWebView{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]];
[_webView loadRequest:request];
}
2017年6月15日
1.網(wǎng)絡(luò)等待框
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
2017年6月13日
UITableView含有UIWebView,如何正確顯示webView高度
2017年6月11日
1.設(shè)置web背景色
[_answerWV stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.background='#2E2E2E'"];
2.web頁面字體放大
法1
CGFloat fontSize = _askLabel.font.pointSize;
NSInteger scale = (fontSize/(14*kFontScale))*100; //14號字體是標(biāo)準(zhǔn)的
NSString *scaleScript = [NSString stringWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%ld%%'",scale];
[_answerWV stringByEvaluatingJavaScriptFromString:scaleScript];
法2
NSString *header1 = @"<head><meta name=\"viewport\" content=\"initial-scale=";
NSString *header2 = @",width=self.view.frame.size.width, maximum-scale=2, minimum-scale=1, user-scalable=yes\"><style>img{max-width: 100%; width:auto; height:auto;}</style><style>*{max-width:100%;max-height:100%}</style></head>";
NSString *scaleHeader = [NSString stringWithFormat:@"%@%0.2lf%@",header1,scale,header2];
NSString *htmlContent = [NSString stringWithFormat:@"<html>%@<body><p style=\"word-break:break-all\">%@</p></body></html>",scaleHeader,model.a];
[_answerWV loadHTMLString:htmlContent baseURL:nil];
2017年5月23日
1.url含中文的pdf格式無法顯示問題解決
NSURL *url = [NSURL URLWithString:[_urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
2017年3月13日
1.webView數(shù)據(jù)加載完成重新計算高度
image.png
如果您發(fā)現(xiàn)本文對你有所幫助,如果您認(rèn)為其他人也可能受益,請把它分享出去。