通信的JavaScript和Objective-C之间(IOS)
我知道的iOS和JavaScript之间的通信的方法是在JS创建假冒的URL并追加将被用来作为参数传递给Objective-C的code串并分析在此委托方法网址:
I know the way to communicate between iOS and javascript is to create fake URLs in JS and append a string which will be used as parameter to the Objective-C code and parse that URL in this delegate method:
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
然后通过调用本地方法发送的返回值 stringByEvaluatingJavaScriptFromString
与参数CALLID一次。
Then send the return value by calling the native method stringByEvaluatingJavaScriptFromString
again with parameter callID.
但我想,就像机器人,直接调用JS从Objective-C的方法,并得到一个返回值。而不是需要来使用JavaScript编写的任何方法来获取返回值。其实我们有JS code了。它完美的作品,同时与Android通信。
But I want to, just like Android, directly call Objective-C methods from JS and get a return value. Instead of needing to write any method in JavaSCript to get the return value. Actually we have JS code already. It works perfectly while communicating with Android.
有没有什么技巧来解决我的问题,这将在AppStore上?
Are there any tricks to solve my problem that will be approved on the AppStore?
您可以通过简单的步骤从调用Objective C的JavaScript方法。
You can call javascript methods from objective C using simple steps.
请通过这
又见苹果文档