diff --git a/tongxin.xcworkspace/xcuserdata/ecell.xcuserdatad/UserInterfaceState.xcuserstate b/tongxin.xcworkspace/xcuserdata/ecell.xcuserdatad/UserInterfaceState.xcuserstate
index bbaf025..4d9359c 100644
Binary files a/tongxin.xcworkspace/xcuserdata/ecell.xcuserdatad/UserInterfaceState.xcuserstate and b/tongxin.xcworkspace/xcuserdata/ecell.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/tongxin.xcworkspace/xcuserdata/ecell.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/tongxin.xcworkspace/xcuserdata/ecell.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
index a4b8eab..a8d7fee 100644
--- a/tongxin.xcworkspace/xcuserdata/ecell.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+++ b/tongxin.xcworkspace/xcuserdata/ecell.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
@@ -697,6 +697,21 @@
endingLineNumber = "261"
offsetFromSymbolStart = "620">
+
+
@@ -790,6 +805,21 @@
endingLineNumber = "239"
offsetFromSymbolStart = "560">
+
+
diff --git a/tongxin/VC/Activity/ActivityWebViewController.h b/tongxin/VC/Activity/ActivityWebViewController.h
index 420f050..4541057 100644
--- a/tongxin/VC/Activity/ActivityWebViewController.h
+++ b/tongxin/VC/Activity/ActivityWebViewController.h
@@ -9,24 +9,13 @@
#import
#import "baseViewController.h"
#import
-#import "MJRefresh.h"
@interface ActivityWebViewController : baseViewController
-@property (nonatomic, strong) WKWebView *myWebView;
@property (nonatomic, strong) NSString *url;
-/**
- 是否显示返回按钮
- */
-@property (nonatomic, assign) BOOL isShowBack;
-
-/**
- 内容 如果为空的时候加载 url
- */
-@property (nonatomic, strong) NSString *content;
diff --git a/tongxin/VC/Activity/ActivityWebViewController.m b/tongxin/VC/Activity/ActivityWebViewController.m
index 03c6dc3..da64d29 100644
--- a/tongxin/VC/Activity/ActivityWebViewController.m
+++ b/tongxin/VC/Activity/ActivityWebViewController.m
@@ -6,455 +6,195 @@
// Copyright © 2019年 weichao. All rights reserved.
//
#import "ActivityWebViewController.h"
-#import
-#import "Reachability.h"
-@interface ActivityWebViewController()
-{
- CGRect WebFrame;
- BOOL _locationAuthorization; // 用户是否授权使用定位
- BOOL _isDidLoadWeb;
-}
-/**
- 隐藏导航栏时有的返回按钮
- */
-@property (nonatomic, strong) UIButton *backBtn;
-@property (nonatomic, strong) UIProgressView *progressView;
-@property (strong,nonatomic) CLLocationManager* locationManager;
-@property (nonatomic, strong) NSString *cityName;
-@property (nonatomic, strong) UIView *tempView;
+@interface ActivityWebViewController ()
+
+@property (nonatomic,strong) WKWebView *wkWebview;
+@property (nonatomic,strong) UIProgressView *progress;
+@property (nonatomic,strong) UIBarButtonItem *leftBarButton;
+@property (nonatomic,strong) UIBarButtonItem *leftBarButtonSecond;
+@property (nonatomic,strong) UIBarButtonItem *negativeSpacer;
+@property (nonatomic,strong) UIBarButtonItem *negativeSpacer2;
@end
+
@implementation ActivityWebViewController
-- (WKWebView *)myWebView{
- if (!_myWebView) {
- //创建 WKWebView 配置对象
-
-
- WKWebViewConfiguration *config = [WKWebViewConfiguration new];
- // config.userContentController = wkUController;
- WKPreferences *preferences = [WKPreferences new];
- preferences.javaScriptCanOpenWindowsAutomatically = YES;
- // preferences.minimumFontSize = 40.0;
- config.preferences = preferences;
- CGFloat tabBarHeight = self.tabBarController.tabBar.height;
-
- CGRect tempViewFrame;
- if(getRectNavAndStatusHight > 64){
- //X
- if(self.isShowBack){
- WebFrame = CGRectMake(0, getRectNavAndStatusHight-44, ScreenWidth, ScreenHeight-tabBarHeight-getRectNavAndStatusHight+44 );
- tempViewFrame = CGRectMake(0, 0, ScreenWidth, getRectNavAndStatusHight-44);
- }else{
- CGFloat WebNacv = 55; //网页的导航栏高度
- WebFrame = CGRectMake(0, getRectNavAndStatusHight-WebNacv, ScreenWidth, ScreenHeight-tabBarHeight-getRectNavAndStatusHight+WebNacv );
- tempViewFrame = CGRectMake(0, 0, ScreenWidth, getRectNavAndStatusHight-WebNacv);
- }
- }else{
- if(self.isShowBack){
- WebFrame = CGRectMake(0, 0, ScreenWidth, ScreenHeight-tabBarHeight);
- tempViewFrame = CGRectMake(0, 0, ScreenWidth, 0);
- }else{
- //不显示返回按钮的是首页
- WebFrame = CGRectMake(0, 20, ScreenWidth, ScreenHeight-tabBarHeight-20);
- tempViewFrame = CGRectMake(0, 0, ScreenWidth, 20);
-
- }
- }
-
- _tempView = [[UIView alloc] initWithFrame:tempViewFrame];
- _tempView.backgroundColor = mainColor;
- [self.view addSubview:_tempView];
- _tempView.hidden = YES;
- _myWebView = [[WKWebView alloc] initWithFrame:WebFrame configuration:config];
- if (@available(iOS 11.0, *)) {
- _myWebView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
- self.edgesForExtendedLayout = UIRectEdgeNone;
- }
-
- [self.view addSubview:_myWebView];
+#pragma mark --- wk
+- (WKWebView *)wkWebview
+{
+ if (_wkWebview == nil)
+ {
+
+ _wkWebview = [[WKWebView alloc]initWithFrame:CGRectMake(0, iPhoneX_NavHeight, ScreenWidth, ScreenHeight-iPhoneX_NavHeight)];
+ _wkWebview.UIDelegate = self;
+ _wkWebview.navigationDelegate = self;
+ _wkWebview.backgroundColor = [UIColor clearColor];
+ _wkWebview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ _wkWebview.multipleTouchEnabled = YES;
+ _wkWebview.autoresizesSubviews = YES;
+ _wkWebview.scrollView.alwaysBounceVertical = YES;
+ _wkWebview.allowsBackForwardNavigationGestures = YES;/**这一步是,开启侧滑返回上一历史界面**/
+ [self.view addSubview:_wkWebview];
}
- return _myWebView;
+ return _wkWebview;
}
--(void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- //隐藏导航栏
- // [[UIApplication sharedApplication] setStatusBarHidden:YES];
- [self.navigationController.navigationBar setHidden:YES];
-
- // addScriptMessageHandler 很容易导致循环引用
- // 控制器 强引用了WKWebView,WKWebView copy(强引用了)configuration, configuration copy (强引用了)userContentController
- // userContentController 强引用了 self (控制器)
-
- [self.myWebView.configuration.userContentController addScriptMessageHandler:self name:@"Location"];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadURL) name:NoReachableRefreshNotification object:nil];
- if(![self.url containsString:ActivityURLStr]){
- xLog(@"不是首页:%@",self.url);
- [self setHiddenTabBottomBar:YES];
- }else{
- xLog(@"是首页:%@",self.url);
- [self setHiddenTabBottomBar:NO];
+#pragma mark 加载进度条
+- (UIProgressView *)progress
+{
+ if (_progress == nil)
+ {
+ _progress = [[UIProgressView alloc]initWithFrame:CGRectMake(0, iPhoneX_NavHeight, ScreenWidth, 0)];
+ _progress.tintColor = [UIColor redColor];
+ _progress.backgroundColor = [UIColor redColor];
+ [self.view addSubview:_progress];
}
-}
--(void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:animated];
-
- // 因此这里要记得移除handlers
- [self.myWebView.configuration.userContentController removeScriptMessageHandlerForName:@"Location"];
-
-}
--(void)viewDidDisappear:(BOOL)animated{
- self.tabBarController.tabBar.hidden = NO;
-
- [[NSNotificationCenter defaultCenter] removeObserver:self name:NoReachableRefreshNotification object:nil];
+ return _progress;
}
-//-(BOOL)prefersStatusBarHidden{
-// if(self.isHiddenNavigationBar){
-// return YES;
-// }else{
-// return NO;
-// }
-//}
-- (void)viewDidLoad{
- self.view.backgroundColor = [UIColor whiteColor];
- self.isSetTranslucent = NO;
- [super viewDidLoad];
- if(!self.url){
- self.url = ActivityURLStr;
- [SVProgressHUD show];
- }
- [self loadURL];
- WEAKSELF
- self.myWebView.UIDelegate = self;
- self.myWebView.navigationDelegate = self;
- self.myWebView.scrollView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
- [weakSelf loadURL];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf.myWebView.scrollView.mj_header endRefreshing];
- });
- }];
-
- if(self.isShowBack){
- UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeSystem];
- backBtn.frame = CGRectMake(14, 40, 30, 30);
- [backBtn setBackgroundImage:[UIImage imageNamed:@"icon_return_black"] forState:0];
- [backBtn addTarget:self action:@selector(goBack:) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:backBtn];
- }
-
-
- [self initProgressView];
- [self initNotReachable];
- [self startLocation];
- // [self.myWebView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil];
- // if(self.isHiddenNavigationBar){
- // //创建返回按钮
- // _backBtn = [UIButton buttonWithType:UIButtonTypeSystem];
- // _backBtn.frame = CGRectMake(5, 26, 30, 30);
- // [_backBtn setBackgroundImage:[UIImage imageNamed:@"icon_return_round"] forState:0];
- // [_backBtn addTarget:self action:@selector(goBack:) forControlEvents:UIControlEventTouchUpInside];
- // [self.view addSubview:_backBtn];
- // }
-}
-- (void)loadURL{
- [self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
- if(!self.cityName && _locationAuthorization){
- [self startLocation];
- }
-}
+- (void)viewWillAppear:(BOOL)animated
+{
+ [super viewWillAppear:animated];
+
+ [self LoadRequest];
+ [self addObserver];
-- (void)initNotReachable{
- [self.view addSubview:self.noDataSourceImageView];
- [self.view addSubview:self.noReachableImageView];
- [self.view addSubview:self.noDataSourcelabel];
- [self.noDataSourceImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(self.myWebView);
- }];
-
- [self.noReachableImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(self.myWebView);
- }];
}
-- (void)initProgressView
+
+#pragma mark 加载网页
+- (void)LoadRequest
{
- CGFloat kScreenWidth = [[UIScreen mainScreen] bounds].size.width;
- UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 2)];
- progressView.tintColor = [UIColor redColor];
- progressView.trackTintColor = [UIColor lightGrayColor];
- [self.view addSubview:progressView];
- self.progressView = progressView;
+ //TODO:加载
+ [self.wkWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
}
-//开始定位
--(void)startLocation{
- if(!self.locationManager){
- self.locationManager = [[CLLocationManager alloc] init];
- self.locationManager.delegate = self;
- self.locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
- // 位置变更距离
- self.locationManager.distanceFilter = 1000.0f;
- if ([CurrentSystemVersion doubleValue] > 8.0){
- if([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined){
- [self.locationManager requestWhenInUseAuthorization];
- }
- }
- // if ([CurrentSystemVersion doubleValue] >= 8.0) {
- // _locationManager.allowsBackgroundLocationUpdates =YES;
- // }
- // [self locationManager:self.locationManager didChangeAuthorizationStatus:[CLLocationManager authorizationStatus]];
- }
- [self.locationManager startUpdatingLocation];
+#pragma mark 添加KVO观察者
+- (void)addObserver
+{
+ //TODO:kvo监听,获得页面title和加载进度值,以及是否可以返回
+ [self.wkWebview addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:NULL];
+ [self.wkWebview addObserver:self forKeyPath:@"canGoBack" options:NSKeyValueObservingOptionNew context:NULL];
+ [self.wkWebview addObserver:self forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:NULL];
}
-//MARK: 协议 CLLocationManagerDelegate
-/**
- 权限改变
- */
--(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status{
- switch (status) {
- case kCLAuthorizationStatusNotDetermined:
- if ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]){
- [self.locationManager requestWhenInUseAuthorization];
- }
- break;
- case kCLAuthorizationStatusDenied:
- xLog(@"用户拒绝获取定位位置");
- _locationAuthorization = NO;
- break;
- case kCLAuthorizationStatusAuthorizedAlways:
- case kCLAuthorizationStatusAuthorizedWhenInUse:
- xLog(@"用户同意获取定位位置");
- if(!self.cityName){
- [self.locationManager startUpdatingLocation];
- }
-
- break;
- default:
- break;
- }
+#pragma mark reload
+- (void)selectedToReloadData
+{
+ [self.wkWebview reload];
}
-/**
- 位置更新
- */
--(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
- //此处locations存储了持续更新的位置坐标值,取最后一个值为最新位置,如果不想让其持续更新位置,则在此方法中获取到一个值之后让locationManager stopUpdatingLocation
- CLLocation *currentLocation = [locations lastObject];
- // 获取当前所在的城市名
- CLGeocoder *geocoder = [[CLGeocoder alloc] init];
- //根据经纬度反向地理编译出地址信息
- WEAKSELF
- [geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray * _Nullable placemarks, NSError * _Nullable error) {
- if (placemarks.count > 0){
- CLPlacemark *placemark = [placemarks objectAtIndex:0];
- //将获得的所有信息显示到label上
- NSLog(@"%@",placemark.name);
- //获取城市
- NSString *city = placemark.locality;
- self.cityName = city;
- if (!city) {
- //四大直辖市的城市信息无法通过locality获得,只能通过获取省份的方法来获得(如果city为空,则可知为直辖市)
- city = placemark.administrativeArea;
- weakSelf.cityName = city;
- //如果这个时候网页已经加载完成了,那就 重新加载一次
- if(_isDidLoadWeb){
- [weakSelf loadURL];
- }
- }else if (error == nil && [placemarks count] == 0){
- NSLog(@"No results were returned.");
- }else if (error != nil){
- NSLog(@"An error occurred = %@", error);
- }
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ self.view.backgroundColor = [UIColor whiteColor];
+ id traget = self.navigationController.interactivePopGestureRecognizer.delegate;
+ UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:traget action:nil];
+ [self.view addGestureRecognizer:pan];
+ [self zx_leftClickedBlock:^(ZXNavItemBtn * _Nonnull btn) {
+ if (self.wkWebview.canGoBack == YES)
+ {
+ [self.wkWebview goBack];
+ }
+ else
+ {
+ [self.navigationController popViewControllerAnimated:YES];
}
}];
-
- //系统会一直更新数据,直到选择停止更新,因为我们只需要获得一次经纬度即可,所以获取之后就停止更新
- [manager stopUpdatingLocation];
}
-- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
- if (error.code == kCLErrorDenied) {
- // 提示用户出错原因,可按住Option键点击 KCLErrorDenied的查看更多出错信息,可打印error.code值查找原因所在
- }
+- (void)didReceiveMemoryWarning {
+ [super didReceiveMemoryWarning];
}
+#pragma mark KVO的监听代理
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
-- (void)dealloc
-{
- NSLog(@"%s",__FUNCTION__);
- self.myWebView.UIDelegate = nil;
- self.myWebView.navigationDelegate = nil;
-
- [[NSNotificationCenter defaultCenter] removeObserver:self name:NoReachableRefreshNotification object:nil];
- // [self.myWebView removeObserver:self forKeyPath:@"estimatedProgress"];
-}
-#pragma mark - private method
-- (void)getLocation
-{
- if(!_locationAuthorization){
- return;
- }
- // 获取位置信息
- if(self.cityName){
- // MARK: 原生 调用 JS
- NSString *city = [self.cityName stringByReplacingOccurrencesOfString:@"市" withString:@""];
- NSString *jsStr = [NSString stringWithFormat:@"setLocation('%@')",city];
- [self.myWebView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
- NSLog(@"%@----%@",result, error);
- }];
- }else{
- //如果定位还未成功那就2秒之后再调用一次
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self getLocation];
- });
+ //加载进度值
+ if ([keyPath isEqualToString:@"estimatedProgress"])
+ {
+ if (object == self.wkWebview)
+ {
+ [self.progress setAlpha:1.0f];
+ [self.progress setProgress:self.wkWebview.estimatedProgress animated:YES];
+ if(self.wkWebview.estimatedProgress >= 1.0f)
+ {
+ [UIView animateWithDuration:1.5f
+ delay:0.0f
+ options:UIViewAnimationOptionCurveEaseOut
+ animations:^{
+ [self.progress setAlpha:0.0f];
+ }
+ completion:^(BOOL finished) {
+ [self.progress setProgress:0.0f animated:NO];
+ }];
+ }
+ }
+ else
+ {
+ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+ }
}
-
-
-}
-
-#pragma mark - KVO
-// 计算wkWebView进度条
-- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
- if (object == self.myWebView && [keyPath isEqualToString:@"estimatedProgress"]) {
- CGFloat newprogress = [[change objectForKey:NSKeyValueChangeNewKey] doubleValue];
- if (newprogress == 1) {
- [self.progressView setProgress:1.0 animated:YES];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- self.progressView.hidden = YES;
- [self.progressView setProgress:0 animated:NO];
- });
-
- }else {
- self.progressView.hidden = NO;
- [self.progressView setProgress:newprogress animated:YES];
+ //网页title
+ else if ([keyPath isEqualToString:@"title"])
+ {
+ if (object == self.wkWebview){
+ self.title = self.wkWebview.title;
+ }else{
+ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
+// //是否可以返回
+// else if ([keyPath isEqualToString:@"canGoBack"])
+// {
+// if (object == self.wkWebview){
+// if (self.wkWebview.canGoBack == 1){
+// self.navigationItem.leftBarButtonItems = @[self.leftBarButton,self.leftBarButtonSecond];
+// }else{
+// self.navigationItem.leftBarButtonItems = @[self.leftBarButton];
+// }
+// }else
+// {
+// [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+// }
+// }else{
+// [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+// }
}
-#pragma mark - WKUIDelegate
-- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
-{
-
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提醒" message:message preferredStyle:UIAlertControllerStyleAlert];
- [alert addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- completionHandler();
- }]];
-
- [self presentViewController:alert animated:YES completion:nil];
-}
-//MARK: 协议 WKNavigationDelegate
-
-/**
- MARK: 页面加载完成之后调用
+#pragma mark 在这里处理短暂性的加载错误
+/*
+ *-1009 没有网络连接
+ *-1003
+ *-999
+ *101
*/
--(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
- _isDidLoadWeb = YES;
- Reachability *reach = [Reachability reachabilityForInternetConnection];
- [SVProgressHUD dismiss];
- if([reach currentReachabilityStatus] == NotReachable){
- xLog(@"无网络");
- _tempView.hidden = YES;
- self.myWebView.hidden = YES;
- [self showNoReachableView];
- [SVProgressHUD showErrorWithStatus:NSLocalizedStringFromTable(@"请检查您的网络设置", @"Localization", @"")];
- [SVProgressHUD dismissWithDelay:1];
- }else{
- xLog(@"有网络");
- [self hiddenNoReachableView];
- _tempView.hidden = NO;
-
- self.myWebView.hidden = NO;
- }
-}
-
-- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler{
- //如果是跳转一个新页面
- if (navigationAction.targetFrame == nil) {
- WEAKSELF
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- ActivityWebViewController* vc = [ActivityWebViewController new];
- vc.url = navigationAction.request.URL.absoluteString;
- vc.isShowBack = YES;
- vc.hidesBottomBarWhenPushed = YES;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- });
- decisionHandler(WKNavigationActionPolicyCancel);
- return;
- }
- self.url = navigationAction.request.URL.absoluteString;
- if(![self.url containsString:ActivityURLStr]){
- xLog(@"不是首页:%@",self.url);
- [self setHiddenTabBottomBar:YES];
- }else{
- xLog(@"是首页:%@",self.url);
- [self setHiddenTabBottomBar:NO];
+- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error
+{
+ NSLog(@"ErrorCode:%ld",error.code);
+ if (error.code == -1099)
+ {
}
- decisionHandler(WKNavigationActionPolicyAllow);
-
-
-}
-
-- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error{
- xLog(@"didFailNavigation error:%@",error.description);
-}
-
-- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error{
- xLog(@"didFailProvisionalNavigation error:%@",error.description);
- [self webView:webView didFinishNavigation:navigation];
}
+#pragma mark 添加返回键和关闭按钮
-
-/**
- 隐藏或者显示 TabBottomBar
- */
--(void)setHiddenTabBottomBar:(BOOL)hidden{
- self.tabBarController.tabBar.hidden = hidden;
-
- if(hidden){
- //隐藏
- self.myWebView.height = WebFrame.size.height+self.tabBarController.tabBar.height;
- }else{
- //显示
- self.myWebView.frame = WebFrame;
- }
-}
-
-- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
- scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
+- (void)viewDidDisappear:(BOOL)animated
+{
+ [super viewDidDisappear:animated];
}
-#pragma mark - WKScriptMessageHandler JS调用 原生会调用这里
-- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+#pragma mark 移除观察者
+- (void)dealloc
{
- // message.body -- Allowed types are NSNumber, NSString, NSDate, NSArray,NSDictionary, and NSNull.
- NSLog(@"body:%@",message.body);
- if ([message.name isEqualToString:@"Location"]) {
- [self getLocation];
- }
- // else if ([message.name isEqualToString:@"Share"]) {
- // [self shareWithParams:message.body];
- // } else if ([message.name isEqualToString:@"Color"]) {
- // [self changeBGColor:message.body];
- // } else if ([message.name isEqualToString:@"Pay"]) {
- // [self payWithParams:message.body];
- // } else if ([message.name isEqualToString:@"Shake"]) {
- // [self shakeAction];
- // } else if ([message.name isEqualToString:@"GoBack"]) {
- // [self goBack];
- // } else if ([message.name isEqualToString:@"PlaySound"]) {
- // [self playSound:message.body];
- // }
+ [self.wkWebview removeObserver:self forKeyPath:@"estimatedProgress"];
+ [self.wkWebview removeObserver:self forKeyPath:@"canGoBack"];
+ [self.wkWebview removeObserver:self forKeyPath:@"title"];
}
+
@end
diff --git a/tongxin/VC/DeviceTab/DeviceTabViewController.m b/tongxin/VC/DeviceTab/DeviceTabViewController.m
index 0c68850..6cf1671 100644
--- a/tongxin/VC/DeviceTab/DeviceTabViewController.m
+++ b/tongxin/VC/DeviceTab/DeviceTabViewController.m
@@ -513,7 +513,8 @@
[self.TitleArr addObject:menuTitleArr3];
}
[self.senerTitleArr addObject:@"定位模式"];
- [self.senerTitleArr addObject:@"拒绝陌生人来电"];
+ if(cUser.cDevice.support_rejectCall && cUser.cDevice.support_rejectCall.intValue == 1)
+ [self.senerTitleArr addObject:@"拒绝陌生人来电"];
if (cUser.cDevice.support_callPhone && cUser.cDevice.support_callPhone.intValue == 1)
[self.senerTitleArr addObject:@"拨号盘开关"];
diff --git a/tongxin/VC/WatchHome/NewHomeVC/HomeHeaderTableView.m b/tongxin/VC/WatchHome/NewHomeVC/HomeHeaderTableView.m
index 610d4e6..bce7184 100644
--- a/tongxin/VC/WatchHome/NewHomeVC/HomeHeaderTableView.m
+++ b/tongxin/VC/WatchHome/NewHomeVC/HomeHeaderTableView.m
@@ -598,7 +598,7 @@
}];
- UILabel *locationAddressLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:Font_(12) textColor:KKTextColor text:@"当前位置未知,请确保设备开机且能够联网,再点击定位按钮进行定位" Radius:0];
+ UILabel *locationAddressLabel = [UICommon ui_label:CGRectZero lines:2 align:NSTextAlignmentLeft font:Font_(12) textColor:KKTextColor text:@"当前位置未知,请确保设备开机且能够联网,再点击定位按钮进行定位" Radius:0];
self.locationAddressLabel = locationAddressLabel;
[_msgView addSubview:locationAddressLabel];
[locationAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
diff --git a/tongxin/xBase/Model/Device.h b/tongxin/xBase/Model/Device.h
index 8c6f913..240a86d 100644
--- a/tongxin/xBase/Model/Device.h
+++ b/tongxin/xBase/Model/Device.h
@@ -225,6 +225,11 @@
@property (nonatomic ,copy) NSNumber *support_scanRecord;
/**
+ 是否支持拒绝陌生人来电
+ */
+@property (nonatomic, copy) NSNumber *support_rejectCall;
+
+/**
设备是否在线
*/
@property (nonatomic ,copy) NSNumber *onlineStatus;