How to make another callback to detect modifyDOM () function?
// alloc webview WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init]; [theConfiguration.userContentController addScriptMessageHandler:self name:@"interOp"]; self.webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) configuration:theConfiguration];
After the modifyDOM () function completes, you call the "interOp" call, and then you can initiate the callback () with any desire and call animateWKWebViewFrame
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message { NSDictionary *sentData = (NSDictionary*)message.body; NSString* command = sentData[@"command"]; LOG(@"[userContentController] command(%@)", command); if ( [command isEqualToString:@"DOMReady"] ) { // defining a JavaScript function NSString *jsFunctionText = @"Initiate({" "command:animateWKWebViewFrame" "});"; [self.webView evaluateJavaScript:jsFunctionText completionHandler:^(id object, NSError * err) { if ( err ) { LOG(@"[evaluateJavaScript] error(%@)", err); } }]; }
source share