当我按照我在 StackOverflow 上找到的答案时,我所需要UIWebView
的touch
只是实现以下内容:
WebVC.h
#import <UIKit/UIKit.h>
@interface WebVC : UIViewController <UIWebViewDelegate, UIGestureRecognizerDelegate>
@property (nonatomic, copy) NSString *test;
@property (strong, nonatomic) IBOutlet UIWebView *webView;
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
@property (strong, nonatomic) UITapGestureRecognizer *tapGestureR;
- (void)handleTap:(id)sender;
@end
WebVC.m
- (void)viewDidLoad
{
[super viewDidLoad];
self.webView.delegate = self;
self.tapGestureR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
self.tapGestureR.delegate = self;
[self.webView addGestureRecognizer:self.tapGestureR];
}
- (void)handleTap:(id)sender
{
NSLog(@"tapDetected");
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return YES;
}
你知道我为什么看不到NSLog
吗?
Method
根本不会被调用。
提前感谢您的帮助。