Jssocials не работают в UIWebView / WKWebView - PullRequest
0 голосов
/ 31 мая 2018

Я хочу использовать плагин jssocial в iOS, нет ответа, когда пользователь нажимает на кнопки, будь то Facebook, Twitter или Instagram из UIWebView, а также не из WKWebView, поэтому, если кто-то внедрил его в iOS, пожалуйста, сообщите мне оЭто.Любая помощь будет ощутимой.Спасибо

1 Ответ

0 голосов
/ 05 июня 2018

Установить свойства WKWebView и делегатов следующим образом

 WKPreferences *prefs = [WKPreferences new];
prefs.javaScriptEnabled = YES;
prefs.javaScriptCanOpenWindowsAutomatically = YES;
WKWebViewConfiguration *theConfig = [[WKWebViewConfiguration alloc] init];
theConfig.preferences = prefs;
webView = [[EasyJSWKWebView alloc] initWithFrame:self.view.bounds
                                       configuration:theConfig
                            withJavascriptInterfaces:interfaces];
    webView.UIDelegate = self;
    webView.navigationDelegate = self;

   [webView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    if (@available(iOS 11.0, *)) {
        webView.scrollView.contentInsetAdjustmentBehavior =  UIScrollViewContentInsetAdjustmentNever;
    }
    [webView loadRequest:requestObj];
    [self.view addSubview:webView];


    - (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:  (WKWindowFeatures *)windowFeatures
  {
ViewPopUp = [[UIView alloc] initWithFrame:self.view.frame];
[ViewPopUp setBackgroundColor:[UIColor whiteColor]];
[self.view addSubview:ViewPopUp];
UIButton *btnBack = [[UIButton alloc] initWithFrame:CGRectMake(0, 20, 50, 50)];
[btnBack setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
[btnBack addTarget:self action:@selector(backButtonClicked) forControlEvents:UIControlEventTouchUpInside];
[ViewPopUp addSubview:btnBack];
PopUpView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height-64) configuration:configuration];
 PopUpView.allowsBackForwardNavigationGestures = YES;
PopUpView.navigationDelegate = self;
[self.view addSubview:PopUpView];
return PopUpView;
 }
...