//
// 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頁(yè)面
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 頁(yè)面很簡(jiǎn)單,先上效果圖 吐槽 某日,暴雨,南京的某個(gè)角落 領(lǐng)導(dǎo): 排面,來一下,我有一個(gè)小想法 。 我:怎么了,海...
- html: 數(shù)據(jù)正在加載中,請(qǐng)稍等...... : js: 1:jq數(shù)據(jù)庫(kù) 2: $(function(){ ...
- 具體問題 安卓手機(jī)HTML5頁(yè)面中input\textarea聚焦時(shí),彈出虛擬鍵盤導(dǎo)致頁(yè)面背景向上移動(dòng),造成頁(yè)面混...
- 有1周沒有寫Affiliate的文章了, 今天寫一片技術(shù)稿來安慰下果粒圈的朋友. 文章標(biāo)題寫,為Affiliate...
- RapidDevelop-Android快速開發(fā)框架 框架持續(xù)更新中 這個(gè)框架是從平時(shí)項(xiàng)目里用的比較多的框架里整合...