如何使檢測modifyDOM()函數的另一個回調?
// 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];
一旦modifyDOM()函數執行完畢,你所說的「互操作」打電話回來,然後你可以回調啓動()與任何希望,並呼籲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);
}
}];
}
你能向我們展示了'modifyDOM()'方法的某些部分?你提到它不包含任何動畫 - 可能你錯了......你是否曾嘗試在'modifyDOM()'和'callNative'之間添加日誌或警報語句,並且可能在'modifyDOM( )'!? – luk2302