How to call Objective-C from Javascript?

前端 未结 8 1687
误落风尘
误落风尘 2020-11-22 17:38

I have a WebView, and I want to call a view in Objective-C from JavaScript. Does someone know how I can do this?


I have this code in my ViewController:

8条回答
  •  暖寄归人
    2020-11-22 17:43

    Like people said here, you have to use the method webView:shouldStartLoadWithRequest:navigationType: from the UIWebviewDelegate.

    This api http://code.google.com/p/jsbridge-to-cocoa/ does it for you. It is very lightweight. You can pass images, strings and arrays from javascript to objective-C.

提交回复
热议问题