我在webview中顯示一個pub或一個pdf文件。但我無法檢測到在web視圖上的觸摸。如何在webview被連續觸摸10秒後顯示一個視圖?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
上述方法,當我接觸到PDF或酒吧file.How的任何文字,我可以檢測其上顯示的PDF或酒吧file.Please幫我out.Thanks web視圖點擊被調用。
編輯:
這是我的代碼:
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:@"http://dblog.com.au"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
UILongPressGestureRecognizer *longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
longPressGestureRecognizer.minimumPressDuration = 6.0;
[self.webView addGestureRecognizer:longPressGestureRecognizer];
[longPressGestureRecognizer release];
}
- (void)handleLongPress:(UIGestureRecognizer *)gestureRecognizer {
NSLog(@"Long press detected");
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
請檢查一下,我有沒有犯任何錯誤?
看起來好吧,你必須添加 youre.h,並設置longPressGestureRecognizer.delegate = self .. –
LarsJK
2010-09-17 11:50:12