//
// HTML5ViewController.m
// XunmallManager
//
// Created by Mac on 2017/2/7.
// Copyright © 2017年 yunmei. All rights reserved.
//
#import "HTML5ViewController.h"
#import <WebKit/WebKit.h>
@interface HTML5ViewController ()<WKUIDelegate,WKNavigationDelegate>
@property (nonatomic ,strong) WKWebView *webView;
@property (nonatomic,strong)UIProgressView *progressView;
@end
@implementation HTML5ViewController
//懒加载
- (WKWebView *)webView
{
if (_webView == nil) {
_webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 64)];
_webView.UIDelegate = self;
_webView.navigationDelegate = self;
_webView.scrollView.bounces = NO;
[self.view addSubview:_webView];
}
return _webView;
}
- (UIProgressView *)progressView
{
if (_progressView == nil) {
_progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 1)];
_progressView.progressTintColor = [UIColor whiteColor];
[self.webView addSubview:_progressView];
}
return _progressView;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"云管理";
[self.webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:NULL];
if (self.urlStr) {
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlStr]]];
}
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqualToString:@"estimatedProgress"]) {
if (object == _webView) {
[self.progressView setAlpha:1.0f];
[self.progressView setProgress:self.webView.estimatedProgress animated:YES];
if(self.webView.estimatedProgress >= 1.0f) {
[UIView animateWithDuration:0.3 delay:0.3 options:UIViewAnimationOptionCurveEaseOut animations:^{
[self.progressView setAlpha:0.0f];
} completion:^(BOOL finished) {
[self.progressView setProgress:0.0f animated:NO];
}];
}
}
else
{
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
-(void)dealloc
{
[self.webView removeObserver:self forKeyPath:@"estimatedProgress"];
self.webView = nil;
}
@end
加载HTML5页面
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 页面很简单,先上效果图 吐槽 某日,暴雨,南京的某个角落 领导: 排面,来一下,我有一个小想法 。 我:怎么了,海...
- html: 数据正在加载中,请稍等...... : js: 1:jq数据库 2: $(function(){ ...
- 具体问题 安卓手机HTML5页面中input\textarea聚焦时,弹出虚拟键盘导致页面背景向上移动,造成页面混...
- 有1周没有写Affiliate的文章了, 今天写一片技术稿来安慰下果粒圈的朋友. 文章标题写,为Affiliate...
- RapidDevelop-Android快速开发框架 框架持续更新中 这个框架是从平时项目里用的比较多的框架里整合...