企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
# js调用ios方法 ## ios ~~~objectivec // js配置 WKUserContentController *userContentController = [[WKUserContentController alloc] init]; //需要JS调用iOS 原生的方法,都要添加到这里 [userContentController addScriptMessageHandler:self name:@"finishHandle"]; // WKWebView的配置 WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init]; configuration.userContentController = userContentController; // 显示WKWebView self.webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-NavitionbarHeight) configuration:configuration]; self.webView.UIDelegate = self; // 设置WKUIDelegate代理 [self.view addSubview:self.webView]; ~~~ ## js ``` js window.webkit.messageHandlers.finishHandle.postMessage('哈哈'); ```