Alex Tau
Alex Tau

Reputation: 2639

protocol method

I am struggling to apply a workaround I found regarding UIWebView accepting tap-events. Source:

http://mithin.in/2009/08/26/detecting-taps-and-events-on-uiwebview-the-right-way/

. The author reminds the reader that he has to implement a '-userDidTapWebView' method, which is declared in a protocol. I don't know where and how to implement this method in order to obtain the desired result. So, I am kindly asking you for help. Thanks in advance for the patience of looking into this!

Upvotes: 1

Views: 643

Answers (1)

kennytm
kennytm

Reputation: 523164

@protocol TapDetectingWindowDelegate
- (void)userDidTapWebView:(id)tapPoint;
@end

This declares a protocol (interfaces in Java/C#/D term), which the adopting class must implement the content of the protocol (i.e. the -userDidTapWebView: method.)

Later in the page,

@interface WebViewController : UIViewController<TapDetectingWindowDelegate>

The <…> means the WebViewController class is adopting the TapDetectingWindowDelegate protocol. Therefore, this class must fulfill the restrictions imposed by this adoption, i.e. the WebViewController must implement -userDidTapWebView:.

The implementation is done in the @implementation, e.g.

@implementation WebViewController
- (void)userDidTapWebView:(id)tapPoint {
    NSLog(@"User tapped web view at point %@.", tapPoint);
}
@end

Upvotes: 1

Related Questions