File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 33static NSString *const CHANNEL_NAME = @" flutter_webview_plugin" ;
44
55// UIWebViewDelegate
6- @interface FlutterWebviewPlugin () <WKNavigationDelegate , UIScrollViewDelegate> {
6+ @interface FlutterWebviewPlugin () <WKNavigationDelegate , UIScrollViewDelegate, WKUIDelegate > {
77 BOOL _enableAppScheme;
88 BOOL _enableZoom;
99}
@@ -105,6 +105,7 @@ - (void)initWebview:(FlutterMethodCall*)call {
105105 }
106106
107107 self.webview = [[WKWebView alloc ] initWithFrame: rc];
108+ self.webview .UIDelegate = self;
108109 self.webview .navigationDelegate = self;
109110 self.webview .scrollView .delegate = self;
110111 self.webview .hidden = [hidden boolValue ];
@@ -260,6 +261,15 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati
260261 }
261262}
262263
264+ - (WKWebView *)webView : (WKWebView *)webView createWebViewWithConfiguration : (WKWebViewConfiguration *)configuration
265+ forNavigationAction : (WKNavigationAction *)navigationAction windowFeatures : (WKWindowFeatures *)windowFeatures {
266+
267+ if (!navigationAction.targetFrame .isMainFrame ) {
268+ [webView loadRequest: navigationAction.request];
269+ }
270+
271+ return nil ;
272+ }
263273
264274- (void )webView : (WKWebView *)webView didStartProvisionalNavigation : (WKNavigation *)navigation {
265275 [channel invokeMethod: @" onState" arguments: @{@" type" : @" startLoad" , @" url" : webView.URL .absoluteString }];
You can’t perform that action at this time.
0 commit comments