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 th开发者_Go百科e patience of looking into this!
@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
精彩评论