UIWebView 将 Objective C 暴露给 JavaScript [英] UIWebView Expose Objective C to JavaScript

查看:24
本文介绍了UIWebView 将 Objective C 暴露给 JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 UIWebView 时,如果使用 iPhone SDK,我将如何在 JavaScript 中公开 Objective-C 方法?

How would I expose an Objective-C method within JavaScript when using the iPhone SDK when using the UIWebView?

任何帮助将不胜感激!

推荐答案

最好的方法是通过自定义链接,然后使用 UIWebView 委托方法 -webView:shouldStartLoadWithRequest:navigationType: 捕获请求.当您看到包含您的链接的请求通过时,您就知道您的操作已被触发.

The best way to do this would be through a custom link, and then use the UIWebView delegate method -webView:shouldStartLoadWithRequest:navigationType: to trap requests. When you see a request come through with your link in it, you know your action has been triggered.

这篇关于UIWebView 将 Objective C 暴露给 JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆