diff --git a/Build/Products/Debug-iphonesimulator/libdsbridge.a b/Build/Products/Debug-iphonesimulator/libdsbridge.a index 85fa401..f7aace2 100644 Binary files a/Build/Products/Debug-iphonesimulator/libdsbridge.a and b/Build/Products/Debug-iphonesimulator/libdsbridge.a differ diff --git a/dsbridge/DWKWebView.h b/dsbridge/DWKWebView.h index 718edf6..929f5a6 100644 --- a/dsbridge/DWKWebView.h +++ b/dsbridge/DWKWebView.h @@ -8,7 +8,7 @@ #import -@interface DWKWebView : WKWebView +@interface DWKWebView : WKWebView @property (nullable, nonatomic, weak) id DSUIDelegate; diff --git a/dsbridge/DWKWebView.m b/dsbridge/DWKWebView.m index 27a51db..363b207 100644 --- a/dsbridge/DWKWebView.m +++ b/dsbridge/DWKWebView.m @@ -172,6 +172,45 @@ -(void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSStri } } +- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures{ + if( self.DSUIDelegate && [self.DSUIDelegate respondsToSelector: + @selector(webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:)]){ + return [self.DSUIDelegate webView:webView createWebViewWithConfiguration:configuration forNavigationAction:navigationAction windowFeatures:windowFeatures]; + } + return nil; +} + +- (void)webViewDidClose:(WKWebView *)webView{ + if( self.DSUIDelegate && [self.DSUIDelegate respondsToSelector: + @selector(webViewDidClose:)]){ + [self.DSUIDelegate webViewDidClose:webView]; + } +} + +- (BOOL)webView:(WKWebView *)webView shouldPreviewElement:(WKPreviewElementInfo *)elementInfo{ + if( self.DSUIDelegate && [self.DSUIDelegate respondsToSelector: + @selector(webView:shouldPreviewElement:)]){ + return [self.DSUIDelegate webView:webView shouldPreviewElement:elementInfo]; + } + return NO; +} + +- (UIViewController *)webView:(WKWebView *)webView previewingViewControllerForElement:(WKPreviewElementInfo *)elementInfo defaultActions:(NSArray> *)previewActions{ + if( self.DSUIDelegate && [self.DSUIDelegate respondsToSelector: + @selector(webView:previewingViewControllerForElement:defaultActions:)]){ + return [self.DSUIDelegate webView:webView previewingViewControllerForElement:elementInfo defaultActions:previewActions]; + } + return nil; +} + + +- (void)webView:(WKWebView *)webView commitPreviewingViewController:(UIViewController *)previewingViewController{ + if( self.DSUIDelegate && [self.DSUIDelegate respondsToSelector: + @selector(webView:commitPreviewingViewController:)]){ + return [self.DSUIDelegate webView:webView commitPreviewingViewController:previewingViewController]; + } +} + - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if(dialogType==1 && alertHandler){ diff --git a/dsbridgedemo/ViewController.h b/dsbridgedemo/ViewController.h index 8f6c272..a4526f3 100644 --- a/dsbridgedemo/ViewController.h +++ b/dsbridgedemo/ViewController.h @@ -7,9 +7,10 @@ // #import +#import "dsbridge.h" #import "JsApiTest.h" -@interface ViewController : UIViewController +@interface ViewController : UIViewController { JsApiTest *jsApi; } diff --git a/dsbridgedemo/ViewController.m b/dsbridgedemo/ViewController.m index 8207035..d2155f2 100644 --- a/dsbridgedemo/ViewController.m +++ b/dsbridgedemo/ViewController.m @@ -7,7 +7,6 @@ // #import "ViewController.h" -#import "dsbridge.h" #import #import "JsEchoApi.h" @interface ViewController () @@ -31,6 +30,8 @@ - (void)viewDidLoad { [dwebview customJavascriptDialogLabelTitles:@{@"alertTitle":@"Notification",@"alertBtn":@"OK"}]; + dwebview.navigationDelegate=self; + // load test.html NSString *path = [[NSBundle mainBundle] bundlePath]; NSURL *baseURL = [NSURL fileURLWithPath:path];