javascript - 从 JavaScript 调用 Objective-C 方法

标签 javascript iphone objective-c

来自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

this question

关于javascript - 从 JavaScript 调用 Objective-C 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16520836/

相关文章:

objective-c - 过滤 [NSWorkspace runningApplications] 以仅包含用户应用程序(无守护程序/UIAgents)

javascript - React/es6 exports createClass 和 extends Component 的区别

javascript - Node.js 中的全局包导入

javascript - 在需要其他模块之前等待异步操作

iPhone:删除所需的缩略图以自定义完整的图像

iphone - 在此代码段中使用 NSThread

c# - 不支持 WPF 调用脚本?

ios - 实现 ScrollView

objective-c - 为什么我不能在开关 block 中创建变量?

objective-c - 消除警告/错误突出显示的 XCode 快捷键?