Browse Source

1. 所有h5页面都隐藏原生导航栏

wanwenkai 1 year ago
parent
commit
7c98bac717

+ 2 - 2
Temperature.xcodeproj/project.pbxproj

@@ -1833,7 +1833,7 @@
 				CODE_SIGN_IDENTITY = "Apple Development";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Manual;
-				CURRENT_PROJECT_VERSION = 20230904;
+				CURRENT_PROJECT_VERSION = 20230907;
 				DEVELOPMENT_TEAM = "";
 				"DEVELOPMENT_TEAM[sdk=iphoneos*]" = FBAS2Y3Z2S;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -1883,7 +1883,7 @@
 				CODE_SIGN_IDENTITY = "Apple Development";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Manual;
-				CURRENT_PROJECT_VERSION = 20230904;
+				CURRENT_PROJECT_VERSION = 20230907;
 				DEVELOPMENT_TEAM = "";
 				"DEVELOPMENT_TEAM[sdk=iphoneos*]" = FBAS2Y3Z2S;
 				FRAMEWORK_SEARCH_PATHS = (

+ 5 - 7
Temperature/ControlModule/Home/Controller/RDSAirControlVC.m

@@ -185,26 +185,25 @@
 
 
 - (IBAction)didTapIcon:(id)sender {
-    [self openPageWithType:@"temp" title:@"温度"];
+    [self openPageWithType:@"temp"];
 }
 
 - (IBAction)didTapHumidity:(id)sender {
-    [self openPageWithType:@"humidity" title:@"湿度"];
+    [self openPageWithType:@"humidity"];
 }
 
 - (IBAction)didTapPm25:(id)sender {
-    [self openPageWithType:@"pm25" title:@"PM 2.5"];
+    [self openPageWithType:@"pm25"];
 }
 
 - (IBAction)didTapCo2:(id)sender {
-    [self openPageWithType:@"co2" title:@"二氧化碳"];
+    [self openPageWithType:@"co2"];
 }
 
-- (void)openPageWithType:(NSString *)type title:(NSString *)title {
+- (void)openPageWithType:(NSString *)type {
     NSString *urlStr = [NSString stringWithFormat:@"%@/#/DataChart/%@/%@", kBaseUrlHeadImg, self.roomModel.record_id, type];
     RDSUserProtocolViewController *vc = [[RDSUserProtocolViewController alloc] init];
     vc.url = urlStr;
-    vc.vcTitle = title;
     [self pushViewController:vc animated:YES];
 }
 
@@ -229,7 +228,6 @@
     }
     RDSUserProtocolViewController *vc = [[RDSUserProtocolViewController alloc] init];
     vc.url = [NSString stringWithFormat:@"%@/#/DeviceInfo/%@", kBaseUrlHeadImg, self.roomModel.record_id];
-    vc.vcTitle = @"设备信息";
     [self pushViewController:vc animated:YES];
 }
 

+ 3 - 4
Temperature/ControlModule/Home/Controller/RDSSubControlVC.m

@@ -116,18 +116,17 @@
 }
 
 - (IBAction)didTapTemperature:(id)sender {
-    [self openPageWithType:@"temp" title:@"温度"];
+    [self openPageWithType:@"temp"];
 }
 
 - (IBAction)didTapHumidity:(id)sender {
-    [self openPageWithType:@"humidity" title:@"湿度"];
+    [self openPageWithType:@"humidity"];
 }
 
-- (void)openPageWithType:(NSString *)type title:(NSString *)title {
+- (void)openPageWithType:(NSString *)type {
     NSString *urlStr = [NSString stringWithFormat:@"%@/#/DataChart/%@/%@", kBaseUrlHeadImg, self.roomModel.record_id, type];
     RDSUserProtocolViewController *vc = [[RDSUserProtocolViewController alloc] init];
     vc.url = urlStr;
-    vc.vcTitle = title;
     [self pushViewController:vc animated:YES];
 }
 

+ 2 - 2
Temperature/ControlModule/Home/Controller/RDSSubControlVC.xib

@@ -141,14 +141,14 @@
                                     <color key="textColor" red="0.1529411765" green="0.18039215689999999" blue="0.23137254900000001" alpha="1" colorSpace="calibratedRGB"/>
                                     <nil key="highlightedColor"/>
                                 </label>
-                                <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_temperature" translatesAutoresizingMaskIntoConstraints="NO" id="uiD-01-wNT">
+                                <imageView clipsSubviews="YES" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_temperature" translatesAutoresizingMaskIntoConstraints="NO" id="uiD-01-wNT">
                                     <rect key="frame" x="60" y="16" width="24" height="24"/>
                                     <gestureRecognizers/>
                                     <connections>
                                         <outletCollection property="gestureRecognizers" destination="iNx-oW-8av" appends="YES" id="vKc-bh-6WZ"/>
                                     </connections>
                                 </imageView>
-                                <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_humidity_g" translatesAutoresizingMaskIntoConstraints="NO" id="Lpc-I3-FYW">
+                                <imageView clipsSubviews="YES" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_humidity_g" translatesAutoresizingMaskIntoConstraints="NO" id="Lpc-I3-FYW">
                                     <rect key="frame" x="154" y="14" width="28" height="28"/>
                                     <gestureRecognizers/>
                                     <connections>

+ 11 - 0
Temperature/Main/LoginRegister/RDSLoginPwdCodeVC.m

@@ -16,6 +16,7 @@
 #import "NSString+verify.h"
 #import "RDSSetPwdVC.h"
 #import "RDSResetPwdVC.h"
+#import "RDSUserProtocolViewController.h"
 
 #import <AuthenticationServices/AuthenticationServices.h>
 
@@ -178,8 +179,18 @@
 }
 
 
+- (IBAction)p_onUserAgreementClick:(id)sender {
+    RDSUserProtocolViewController *userProtocolVC = [[RDSUserProtocolViewController alloc] init];
+    userProtocolVC.url = kUserAgreement;
+    [self pushViewController:userProtocolVC animated:YES];
+}
 
 
+- (IBAction)p_onPrivacyPolicyClick:(id)sender {
+    RDSUserProtocolViewController *userProtocolVC = [[RDSUserProtocolViewController alloc] init];
+    userProtocolVC.url = kPrivacyPolicy;
+    [self pushViewController:userProtocolVC animated:YES];
+}
 
 
 

+ 7 - 1
Temperature/Main/LoginRegister/RDSLoginPwdCodeVC.xib

@@ -3,7 +3,7 @@
     <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -170,6 +170,9 @@
                             <state key="normal" title="《用户协议》">
                                 <color key="titleColor" red="0.027450980390000001" green="0.70196078429999997" blue="0.72549019609999998" alpha="1" colorSpace="calibratedRGB"/>
                             </state>
+                            <connections>
+                                <action selector="p_onUserAgreementClick:" destination="-1" eventType="touchUpInside" id="BWD-SA-6Hh"/>
+                            </connections>
                         </button>
                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="以及" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5iv-7s-LKk">
                             <rect key="frame" x="184" y="0.0" width="25" height="30"/>
@@ -183,6 +186,9 @@
                             <state key="normal" title="《隐私政策》">
                                 <color key="titleColor" red="0.027450980390000001" green="0.70196078429999997" blue="0.72549019609999998" alpha="1" colorSpace="calibratedRGB"/>
                             </state>
+                            <connections>
+                                <action selector="p_onPrivacyPolicyClick:" destination="-1" eventType="touchUpInside" id="jSX-D2-RGz"/>
+                            </connections>
                         </button>
                     </subviews>
                 </stackView>

+ 0 - 2
Temperature/Main/LoginRegister/RDSLoginVerifyCodeVC.m

@@ -197,7 +197,6 @@
     
     RDSUserProtocolViewController *userProtocolVC = [[RDSUserProtocolViewController alloc] init];
     userProtocolVC.url = kUserAgreement;
-    userProtocolVC.vcTitle = @"用户服务协议";
     [self pushViewController:userProtocolVC animated:YES];
 }
 
@@ -206,7 +205,6 @@
     
     RDSUserProtocolViewController *userProtocolVC = [[RDSUserProtocolViewController alloc] init];
     userProtocolVC.url = kPrivacyPolicy;
-    userProtocolVC.vcTitle = @"隐私政策";
     [self pushViewController:userProtocolVC animated:YES];
 }
 

+ 2 - 2
Temperature/Main/LoginRegister/RDSLoginVerifyCodeVC.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="retina6_0" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>

+ 2 - 1
Temperature/Main/LoginRegister/RDSUserProtocolViewController.h

@@ -10,6 +10,7 @@
 
 @interface RDSUserProtocolViewController : RDSBaseViewController
 
-@property(nonatomic, copy) NSString *url;
+@property (nonatomic, copy) NSString *url;
 @property (nonatomic, copy) NSString *vcTitle;
+
 @end

+ 44 - 24
Temperature/Main/LoginRegister/RDSUserProtocolViewController.m

@@ -9,57 +9,77 @@
 #import "RDSUserProtocolViewController.h"
 #import <WebKit/WebKit.h>
 
-@interface RDSUserProtocolViewController ()<WKUIDelegate,WKNavigationDelegate>
+@interface RDSUserProtocolViewController () <WKUIDelegate, WKNavigationDelegate, WKScriptMessageHandler>
 @property (nonatomic, strong) WKWebView *webView;
 
 @end
 
 @implementation RDSUserProtocolViewController
 
+- (void)dealloc {
+    WKUserContentController *controller = self.webView.configuration.userContentController;
+    [controller removeScriptMessageHandlerForName:@"closePage"];
+}
+
 - (void)viewDidLoad {
     [super viewDidLoad];
-    
+
     self.title = _vcTitle;
     [self p_setupUI];
-    
+
     [self p_loadData];
-    
 }
 
--(void) p_loadData{
+- (void)viewWillAppear:(BOOL)animated {
+    [super viewWillAppear:animated];
+    [self.navigationController setNavigationBarHidden:YES];
+}
+
+- (void)viewWillDisappear:(BOOL)animated {
+    [super viewWillDisappear:animated];
+    [self.navigationController setNavigationBarHidden:NO];
+}
+
+- (void)p_loadData {
     /* 加载服务器url的方法*/
     NSString *url = self.url;
     NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
     [_webView loadRequest:request];
 }
 
--(void) p_setupUI{
-    
-    self.webView = [[WKWebView alloc] init];
+- (void)p_setupUI {
+    WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
+    [configuration.userContentController addScriptMessageHandler:self name:@"closePage"];
     
+    self.webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration];
+
     // 放在AppDelegate中全局修改
-//    [_webView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id _Nullable result, NSError * _Nullable error) {
-//        NSString *newUserAgent = [result stringByAppendingFormat:@"/%@", @"yongxulvjian"];
-//        [[NSUserDefaults standardUserDefaults] registerDefaults:@{@"UserAgent":newUserAgent}];
-//    }];
-    
+    //    [_webView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id _Nullable result, NSError * _Nullable error) {
+    //        NSString *newUserAgent = [result stringByAppendingFormat:@"/%@", @"yongxulvjian"];
+    //        [[NSUserDefaults standardUserDefaults] registerDefaults:@{@"UserAgent":newUserAgent}];
+    //    }];
+
     [self.view addSubview:_webView];
     [_webView mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.left.equalTo(self.view);
-        make.right.equalTo(self.view);
-        make.top.equalTo(self.view);
-        if (@available(iOS 11.0, *)) {
-            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
-        } else {
-            make.bottom.equalTo(self.view.mas_bottom);
-        }
+//        make.left.equalTo(self.view);
+//        make.right.equalTo(self.view);
+//        make.top.equalTo(self.view);
+//        if (@available(iOS 11.0, *)) {
+//            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
+//        } else {
+//            make.bottom.equalTo(self.view.mas_bottom);
+//        }
+        make.edges.mas_equalTo(UIEdgeInsetsZero);
     }];
     _webView.UIDelegate = self;
     _webView.navigationDelegate = self;
     _webView.allowsBackForwardNavigationGestures = YES;
-    
-    
-    
+}
+
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message {
+    if ([message.name isEqualToString:@"closePage"]) {
+        [self.navigationController popViewControllerAnimated:YES];
+    }
 }
 
 @end