Skip to content

Commit

Permalink
add initWithCoder and commonInit
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Fung-GGL committed May 27, 2020
1 parent f0e3c72 commit 937a32e
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions dsbridge/DWKWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,26 @@ @implementation DWKWebView
bool isDebug;
}

-(instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
[self commonInit];
}
return self;
}

-(instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration
{
self = [super initWithFrame:frame configuration: configuration];
if (self) {
[self commonInit];
}
return self;
}

-(void)commonInit{
super.UIDelegate=self;
txtName=nil;
dialogType=0;
callId=0;
Expand All @@ -46,16 +63,12 @@ -(instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration
WKUserScript *script = [[WKUserScript alloc] initWithSource:@"window._dswk=true;"
injectionTime:WKUserScriptInjectionTimeAtDocumentStart
forMainFrameOnly:YES];
[configuration.userContentController addUserScript:script];
self = [super initWithFrame:frame configuration: configuration];
if (self) {
super.UIDelegate=self;
}
[self.configuration.userContentController addUserScript:script];

// add internal Javascript Object
InternalApis * interalApis= [[InternalApis alloc] init];
interalApis.webview=self;
[self addJavascriptObject:interalApis namespace:@"_dsb"];
return self;
}

- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt
Expand Down

0 comments on commit 937a32e

Please sign in to comment.