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