我想将 UIGestureRecognizerDelegate 添加到 UIWebView,但失败了。
如果 [self.view addsubView:webView]; 所以 UIWebView 可以,但 UIGestureRecognizerDelegate 不行。
如果删除 [self.view addsubView:webView]; 所以 UIGestureRecognizerDelegate 没问题,但什么也看不到。
- (void)viewDidLoad {
[super viewDidLoad];
webView= [[UIWebView alloc] initWithFrame:CGRectMake(0.0f, -2.0f, 320.0f, 415.0f)];
if (_refreshHeaderView == nil) {
webScroller = (UIScrollView *)[[webView subviews] objectAtIndex:0];
[webScroller setDelegate:self];
EGORefreshTableHeaderView *view = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - webScroller.bounds.size.height, self.view.frame.size.width, webScroller.bounds.size.height)];
view.delegate = self;
[webScroller addSubview:view];
_refreshHeaderView = view;
}
[_refreshHeaderView refreshLastUpdatedDate];
[self.view addSubview:self.webView];
// Set up recognizers.
UITapGestureRecognizer *doubleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
doubleTapRecognizer.numberOfTapsRequired = 2;
doubleTapRecognizer.delegate = self;
[self.view addGestureRecognizer:doubleTapRecognizer];
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
tapRecognizer.delegate = self;
[self.view addGestureRecognizer:tapRecognizer];
}