views:

39

answers:

1

Newbie Question.

I have a UIWebView that I push HTML code into. In the HTML code is an image. Is there a way to get informed that image #3 or image with name 'bob' was touched ? Some event like 'didImageWasClickedAndHereIsTheIDOfTheClickedThingy' perhaps?

+1  A: 

I don't think there is a good way to do this that is directly supported by UIWebView, but there is a slightly hacky way.

Add JavaScript onclick handlers to your images that do something like this:

function (imgElement) {
    document.location = "http://myapp/didClick/" + imgElement.id;
}

When the user taps the image, a request will me made, which can be intercepted by your app by implementing webView:shouldStartLoadWithRequest:navigationType: on the UIWebView's delegate.

Will Harris
Very interesting way indeed.hmmm...
BahaiResearch.com