开发者

How do I trigger execution of a method within an iPhone application from Javascript?

Is it possible to trigger the execution of a method within an iPhone applicatio开发者_C百科n from JavaScript on a web page?

For example, I'd like to have a button that opens the iPhone camera application. Is this possible?


The question is worded a bit confusingly, but if you're displaying a UIWebView in an app and want to have Javascript from the webpage interact with the app, this can be done using the webView:shouldStartLoadWithRequest:navigationType: delegate method. See Apple's documentation: http://developer.apple.com/iphone/library/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html

If you are trying to open the Camera app from an actual webpage running in Safari, you're out of luck. You can only open apps with associated URLs. (For example, tel: URLs to make phone calls, itms: URLs to launch the iTunes Store or App Store, etc).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜