Jssocials 在 UIWebView/WKWebView 中不起作用



我想在iOS中使用jssocial插件,当用户点击来自UIWebView的Facebook,Twitter或Instagram按钮时没有响应,也不是来自WKWebView,所以,如果有人在iOS中实现了它,那么请指导我。 任何帮助都将是可观的。谢谢

按如下方式设置 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;
}

相关内容

  • 没有找到相关文章

最新更新