ios wkwebview 是否有缓存
1个回答
展开全部
1:获取webviewscrovllviewcontentsize进行设置
-(void)webViewDidFinishLoad:(UIWebView
*)webView{
CGFloat
webViewHeight=[webView.scrollView
contentSize].height;
CGRect
newFrame
=
webView.frame;
newFrame.size.height
=
webViewHeight;
webView.frame
=
newFrame;
}
2:执行js语句 直接获取html文档dom高度
-(void)webViewDidFinishLoad:(UIWebView
*)webView{
CGFloat
webViewHeight=
[[webView
stringByEvaluatingJavaScriptFromString:
@"document.body.offsetHeight"]floatValue];
// CGFloat webViewHeight= [[webView
stringByEvaluatingJavaScriptFromString:
@"document.body.scrollHeight"]floatValue];
CGRect
newFrame
=
webView.frame;
newFrame.size.height
=
webViewHeight;
webView.frame
=
newFrame;
}
3.先UIWebView高度设再使用sizeThatFits返刚合适
-(void)webViewDidFinishLoad:(UIWebView
*)webView{
CGSize
actualSize
=
[webView
sizeThatFits:CGSizeZero];
CGRect
newFrame
=
webView.frame;
newFrame.size.height
=
actualSize.height;
webView.frame
=
newFrame;
}
4.遍历webview视图 获取UIWebDocumentView高度即实际高度
Objective-C
-(void)webViewDidFinishLoad:(UIWebView
*)webView{
CGFloat
webViewHeight
=
0.0f;
if
([webView.subviews
count]
>
0)
{
UIView
*scrollerView
=
webView.subviews[0];
if
([scrollerView.subviews
count]
>
0)
{
UIView
*webDocView
=
scrollerView.subviews.lastObject;
if
([webDocView
isKindOfClass:[NSClassFromString(@"UIWebDocumentView")
class]])
{
webViewHeight
=
webDocView.frame.size.height;//获取文档高度
webView.frame=
webDocView.frame;
//更新UIWebView 高度
}
}
}
}
-(void)webViewDidFinishLoad:(UIWebView
*)webView{
CGFloat
webViewHeight=[webView.scrollView
contentSize].height;
CGRect
newFrame
=
webView.frame;
newFrame.size.height
=
webViewHeight;
webView.frame
=
newFrame;
}
2:执行js语句 直接获取html文档dom高度
-(void)webViewDidFinishLoad:(UIWebView
*)webView{
CGFloat
webViewHeight=
[[webView
stringByEvaluatingJavaScriptFromString:
@"document.body.offsetHeight"]floatValue];
// CGFloat webViewHeight= [[webView
stringByEvaluatingJavaScriptFromString:
@"document.body.scrollHeight"]floatValue];
CGRect
newFrame
=
webView.frame;
newFrame.size.height
=
webViewHeight;
webView.frame
=
newFrame;
}
3.先UIWebView高度设再使用sizeThatFits返刚合适
-(void)webViewDidFinishLoad:(UIWebView
*)webView{
CGSize
actualSize
=
[webView
sizeThatFits:CGSizeZero];
CGRect
newFrame
=
webView.frame;
newFrame.size.height
=
actualSize.height;
webView.frame
=
newFrame;
}
4.遍历webview视图 获取UIWebDocumentView高度即实际高度
Objective-C
-(void)webViewDidFinishLoad:(UIWebView
*)webView{
CGFloat
webViewHeight
=
0.0f;
if
([webView.subviews
count]
>
0)
{
UIView
*scrollerView
=
webView.subviews[0];
if
([scrollerView.subviews
count]
>
0)
{
UIView
*webDocView
=
scrollerView.subviews.lastObject;
if
([webDocView
isKindOfClass:[NSClassFromString(@"UIWebDocumentView")
class]])
{
webViewHeight
=
webDocView.frame.size.height;//获取文档高度
webView.frame=
webDocView.frame;
//更新UIWebView 高度
}
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询