UIWebView Expose Objective C to JavaScript

◇◆丶佛笑我妖孽 提交于 2019-11-28 20:23:02

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.

Lee

There is an example application in the QuickConnectiPhone framework that shows you how to do this.

QuickConnectiPhone also gives you a JavaScript function called 'makeCall'. You pass it a command and an array of parameters and it will pass them to the Objective-C side of your app for handling. You can then make your function call.

You can find it here on Sourceforge.

To see an example of this check out the PhoneGap source code from Github:

http://github.com/sintaxi/phonegap/tree/master/iphone/Classes/GlassAppDelegate.m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!