Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add initWithCoder and commonInit #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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