From 57e30bc2584b92ce3da3821bd0f6e040f2ad28df Mon Sep 17 00:00:00 2001
From: admin <lrj@aelines-MacBook-Air.local>
Date: 星期五, 21 四月 2023 18:08:07 +0800
Subject: [PATCH] 抖音SDK 升级,个人中心bug修改,增加

---
 BuWanVideo2.0/SettingWebView.m |   68 ++++++++++++++++++++++++++++++++--
 1 files changed, 64 insertions(+), 4 deletions(-)

diff --git a/BuWanVideo2.0/SettingWebView.m b/BuWanVideo2.0/SettingWebView.m
index d93f44f..551d4c0 100755
--- a/BuWanVideo2.0/SettingWebView.m
+++ b/BuWanVideo2.0/SettingWebView.m
@@ -7,9 +7,12 @@
 //
 
 #import "SettingWebView.h"
-#import <WebKit/WebKit.h>
+#import "dsbridge.h"
+#import "JSAPI.h"
 
 @interface SettingWebView ()
+
+@property (nonatomic, nullable, strong) DWKWebView *webView;
 
 @end
 
@@ -46,12 +49,63 @@
         height = 84;
     }
     
-    WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, KScreenW, KScreenH - height)];
-    [self.view addSubview: webView];
+//    WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, KScreenW, KScreenH - height)];
+    [self.view addSubview: self.webView];
+    [self.webView addJavascriptObject:[[JSAPI alloc] init] namespace:@"yestv"];
     NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:_requestURL]];
-    [webView loadRequest:request];
+    [_webView loadRequest:request];
     // Do any additional setup after loading the view from its nib.
 }
+
+
+- (DWKWebView *)webView {
+    if (!_webView) {
+        // 0.缃戦〉閰嶇疆瀵硅薄
+        WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
+        // 1.鍘熺敓涓嶫S浜や簰绠$悊
+        WKUserContentController *userContentController = [[WKUserContentController alloc] init];
+        
+        // 娣诲姞
+        config.userContentController = userContentController;
+        
+        // 3.WKWebview璁剧疆
+        WKPreferences *prefer = [[WKPreferences alloc] init];
+        //璁剧疆鏄惁鏀寔javaScript 榛樿鏄敮鎸佺殑
+        prefer.javaScriptEnabled = YES;
+        // // 鍦╥OS涓婇粯璁や负NO锛岃〃绀烘槸鍚﹀厑璁镐笉缁忚繃鐢ㄦ埛浜や簰鐢眏avaScript鑷姩鎵撳紑绐楀彛
+        prefer.javaScriptCanOpenWindowsAutomatically = YES;
+        // 娣诲姞
+        config.preferences = prefer;
+        config.preferences.minimumFontSize = 0.0f;
+        // 鏄娇鐢╤5鐨勮棰戞挱鏀惧櫒鍦ㄧ嚎鎾斁, 杩樻槸浣跨敤鍘熺敓鎾斁鍣ㄥ叏灞忔挱鏀�
+        config.allowsInlineMediaPlayback = YES;
+        //璁剧疆瑙嗛鏄惁闇�瑕佺敤鎴锋墜鍔ㄦ挱鏀�  璁剧疆涓篘O鍒欎細鍏佽鑷姩鎾斁
+        config.mediaTypesRequiringUserActionForPlayback = YES;
+        //璁剧疆鏄惁鍏佽鐢讳腑鐢绘妧鏈� 鍦ㄧ壒瀹氳澶囦笂鏈夋晥
+        config.allowsPictureInPictureMediaPlayback = YES;
+        //璁剧疆璇锋眰鐨刄ser-Agent淇℃伅涓簲鐢ㄧ▼搴忓悕绉� iOS9鍚庡彲鐢�
+        config.applicationNameForUserAgent = @"ChinaDailyForiPad";
+        
+        config.suppressesIncrementalRendering = YES;
+        
+        CGFloat height = 64;
+        if (KIsiPhoneX) {
+            height = 84;
+        }
+        
+        _webView = [[DWKWebView alloc] initWithFrame:CGRectMake(0, 0, KScreenW, KScreenH - height) configuration:config];
+        
+        _webView.DSUIDelegate = self;
+        _webView.navigationDelegate = self;
+        
+        // 鏄惁鍏佽鎵嬪娍宸︽粦杩斿洖涓婁竴绾�, 绫讳技瀵艰埅鎺у埗鐨勫乏婊戣繑鍥�
+        _webView.allowsBackForwardNavigationGestures = YES;
+        //鍙繑鍥炵殑椤甸潰鍒楄〃, 瀛樺偍宸叉墦寮�杩囩殑缃戦〉
+        //WKBackForwardList * backForwardList = [_webView backForwardList];
+    }
+    return _webView;
+}
+
 -(void)presentBack{
     [self dismissViewControllerAnimated:YES completion:^{
         //鐘舵�佹爮閲嶇幇
@@ -65,6 +119,12 @@
 }
 
 -(void)back:(id)sender{
+    if(_webView!=nil){
+        if([_webView canGoBack]){
+            [_webView goBack];
+            return;
+        }
+    }
     [self.navigationController popViewControllerAnimated:YES];
 }
 

--
Gitblit v1.8.0