来自documentation ,除了突出显示的那句话之外,似乎是可能的:
The web scripting capabilities of WebKit permit you to access Objective-C properties and call Objective-C methods from the JavaScript scripting environment.
An important but not necessarily obvious fact about this bridge is that it does not allow any JavaScript script to access Objective-C. You cannot access Objective-C properties and methods from a web browser unless a custom plug-in has been installed. The bridge is intended for people using custom plug-ins and JavaScript environments enclosed within WebKit objects (for example, a WebView).
或者我应该考虑 Sixten Otto 显示的解决方案 here ? 我想做的是:当用户点击 UIWebView 中的图像时,JavaScript 例程调用 Objective-C 中的方法。
最佳答案
你看到这个了吗JavaScriptFromObjC
关于javascript - 从 JavaScript 调用 Objective-C 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16520836/