Pergunta

From documentation, it seems to be possible except for the sentence highlighted :

The web scripting capabilities of WebKit permit you to access Objective-C properties and call Objective-C methods from the JavaScript scripting environment.

An important but not necessarily obvious fact about this bridge is that it does not allow any JavaScript script to access Objective-C. You cannot access Objective-C properties and methods from a web browser unless a custom plug-in has been installed. The bridge is intended for people using custom plug-ins and JavaScript environments enclosed within WebKit objects (for example, a WebView).

Or should I consider the solution from Sixten Otto shown here ? What I wish to do is : when user tap on an image in UIWebView a JavaScript routine calls a method in Objective-C.

Foi útil?

Solução

Did you see this JavaScriptFromObjC

and this question

Outras dicas

Take a look at open source project Apache Cordova. You'll learn how to interact with native code for other mobile platforms, too.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top