iOS UIWebView 无法确定web页面的真实高度
来源:互联网 发布:编程证明哥德巴赫猜想 编辑:程序博客网 时间:2024/05/18 02:37
@interface
IndEditorDetailViewController ()<uiwebviewdelegate, njkwebviewprogressdelegate=
""
>
{
UIWebView *_webView;
UIProgressView *_progressView;
NJKWebViewProgress *_progressProxy;
}
@end
@implementation
IndEditorDetailViewController
- (
void
)viewDidLoad {
_progressView = [[UIProgressView alloc] init];
_progressView.frame = CGRectMake(
0
,
0
,
320
,
10
);
[self.view addSubview:_progressView];
_progressProxy = [[NJKWebViewProgress alloc] init];
_webView.delegate = _progressProxy;
_progressProxy.webViewProxyDelegate = self;
_progressProxy.progressDelegate = self;
}
- (
void
)webViewDidFinishLoad:(UIWebView *)webView{
// 一般获取网页高度会在这个方法里获取
// 但这里获取的高度未必就是web页面的真实高度,因为web中图片未加载完有可能导致web界面不真实,或长或短
// 你能可能用到下面的js方法去获取,但其实都没用
/**
1、document.documentElement.offsetHeight;
2、document.body.clientHeight;
3、document.documentElement.scrollHeight
4、
CGRect frame = webView.frame;
CGSize fittingSize = [webView sizeThatFits:CGSizeZero];
frame.size = fittingSize;
webView.frame = frame;
5、getBodyHeight() // 网页用js实现好的方法
6、CGFloat height = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.clientHeight"] floatValue];
*/
// 所以必须要找到能完全确定web加载,才能确定web高度
// 在网上找了个工具 NJKWebViewProgress
}
#pragma mark - NJKWebViewProgressDelegate
-(
void
)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(
float
)progress
{
if
(progress ==
0.0
) {
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
_progressView.progress =
0
;
[UIView animateWithDuration:
0.27
animations:^{
_progressView.alpha =
1.0
;
}];
}
if
(progress ==
1.0
) {
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
[UIView animateWithDuration:
0.27
delay:progress - _progressView.progress options:
0
animations:^{
_progressView.alpha =
0.0
;
// webView彻底加载完
CGFloat height = [[_webView stringByEvaluatingJavaScriptFromString:@
"document.body.clientHeight"
] floatValue];
CGRect frame = _webView.frame;
frame.size.height = height;
_webView.frame = frame;
} completion:nil];
}
[_progressView setProgress:progress animated:NO];
}
@end
</uiwebviewdelegate,>
0 0
- iOS UIWebView 无法确定web页面的真实高度
- iOS UIWebView 无法确定web页面的真实高度
- iOS 获取UIWebView的高度
- iOS之UIWebView无法获取web标题
- iOS 计算 UIWebView 的高度的问题
- ios 关于UIWebView的高度问题
- iOS-OC-获取UIWebview的高度
- IOS计算UIWebView的实际高度
- ios开发-确定/自适应textView的高度
- 【iOS】UITableView 动态确定cell的高度
- iOS的WebView自适应内容高度(真实高度)
- UIScrollView内嵌套UIWebView时,因为无法取得UIWebView的实际高度无法滚动的问题
- IOS的UIWebView加载页面空白问题
- UIWebView的高度问题
- 获取UIWebView的高度
- 计算UIWebView的高度
- iOS动态获取UIWebView高度
- iOS动态获取UIWebView高度
- Hash
- 每天进步一点点——load data infile的相关优化
- BAPI_GOODSMVT_CREATE
- Duilib界面库Capture系列的相关bug解决
- linux 编辑 php 扩展
- iOS UIWebView 无法确定web页面的真实高度
- android shape使用总结
- POJ 3126 Prime Path
- fork函数详解
- MEAN架构Angular fullstack generator生成器
- Introduction to Java Programming编程题6.1<为学生分数转换为ABCDF>
- JAVA IO流(2)
- 快速排序(Java)
- 基于Jenkins+git+gradle的android持续集成