forked from dukeland/EasyJSWebView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EasyJSWebView.m
60 lines (49 loc) · 1.61 KB
/
EasyJSWebView.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// EasyJSWebView.m
// EasyJS
//
// Created by Lau Alex on 19/1/13.
// Modified by 腹黒い茶 on 2/3/2015.
// Copyright (c) 2013 Dukeland. All rights reserved.
//
#import "EasyJSWebView.h"
#import "EasyJSWebViewProxyDelegate.h"
@interface WKWebView ()
- (id)webView:(id)view identifierForInitialRequest:(id)initialRequest fromDataSource:(id)dataSource;
- (void)webView:(id)view resource:(id)resource didFinishLoadingFromDataSource:(id)dataSource;
- (void)webView:(id)view resource:(id)resource didFailLoadingWithError:(id)error fromDataSource:(id)dataSource;
@end
@implementation EasyJSWebView
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration {
self = [super initWithFrame:frame configuration:configuration];
if (self) {
}
return self;
}
- (id)init {
self = [super init];
if (self) {
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self){
}
return self;
}
- (void)addJavascriptInterfaces:(NSObject *)interface WithName:(NSString *)name {
id<WKNavigationDelegate> delegate = self.navigationDelegate;
NSLog(@"%@, %d", [delegate class], [delegate isKindOfClass:[EasyJSWebViewProxyDelegate class]]);
if (delegate != nil && [delegate isKindOfClass:[EasyJSWebViewProxyDelegate class]]) {
EasyJSWebViewProxyDelegate *proxyDelegate = (EasyJSWebViewProxyDelegate *)delegate;
[proxyDelegate addJavascriptInterfaces:interface WithName:name];
}
}
@end