Procházet zdrojové kódy

feat(WKwebview): Allow _target links to be opened up in the same way as UIWebView. (#270)

Fixes #139
Benjos Antony před 5 roky
rodič
revize
6643a8e38d
1 změnil soubory, kde provedl 11 přidání a 0 odebrání
  1. 11
    0
      ios/RNCWKWebView.m

+ 11
- 0
ios/RNCWKWebView.m Zobrazit soubor

@@ -73,6 +73,17 @@ static NSString *const MessageHanderName = @"ReactNative";
73 73
   return self;
74 74
 }
75 75
 
76
+/**
77
+ * See https://stackoverflow.com/questions/25713069/why-is-wkwebview-not-opening-links-with-target-blank/25853806#25853806 for details.
78
+ */
79
+- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
80
+{
81
+  if (!navigationAction.targetFrame.isMainFrame) {
82
+    [webView loadRequest:navigationAction.request];
83
+  }
84
+  return nil;
85
+}
86
+
76 87
 - (void)didMoveToWindow
77 88
 {
78 89
   if (self.window != nil && _webView == nil) {