views:

264

answers:

2

I am using a webview and on that web view i have a image. I want to know how i detect touch event of image of webview. I have o open a new view when image is touch.

A: 

UIWebView inherits from UIView so you could try overriding:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event

Not sure how much control of the contents of the UIWebView you will have though and if you will be able to figure out the location of the image.

willcodejavaforfood
A: 

Depending on the content of the webView, you might have success turning the image into a link, then in your UIWebViewDelegate, implement the webView:shouldStartLoadWithRequest:navigationType: method and check for the image link's URL using the (NSURLRequest *)request parameter.

If you don't have control of the webView's HTML content, but the image does have an ID, you could make it a link using UIWebView's stringByEvaluatingJavaScriptFromString: method to run some javascript and "linkify" the image.

Kirk van Gorkom