2010-03-09 128 views

回答

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

声明一个协议(在Java中/ C#/ d术语接口),其采用类必须实现协议的内容(即,-userDidTapWebView:方法。)

在后来的页面,

@interface WebViewController : UIViewController<TapDetectingWindowDelegate> 

<…>意味着WebViewController类采用吨他TapDetectingWindowDelegate协议。因此,该类必须满足此采用所施加的限制,即WebViewController必须实现-userDidTapWebView:

该实现在@implementation中完成,例如,

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