D
D
DjPROgramiST2014-07-25 15:16:12
iOS
DjPROgramiST, 2014-07-25 15:16:12

How to detect click on image in UIWebView in iOS?

It is necessary to execute a certain method on clicking on the image

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
agee, 2014-07-25
@agee

You can execute your JS code in the context of the UIWebView page https://developer.apple.com/library/ios/documentat...
In this JS code, for example, hang handlers on the onclick event on all pages and pass them to this handler the element itself or, for example, a link to the image itself. In the event handler, you can redirect to some url like mypotocol://myurl.
And now, in the webView:shouldStartLoadWithRequest:navigationType: delegate method, define the protocol and url, and if it matches mypotocol and / or myurl, then perform the necessary actions, while returning NO.

P
PKochubey, 2014-07-25
@PKochubey

Implementing https://github.com/marcuswestin/WebViewJavascriptBridge will be much easier and more correct.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question