我有一個uiwebview在uipageviewcontroller裏面,我希望能夠在視圖中選擇一些文本,所以我有userInteractionEnabled設置爲YES,但是當我這樣做時,我沒有選擇轉動通過點擊頁面,雖然刷卡仍然正常工作。uiwebview裏面的uipageviewcontroller塊點擊翻頁
在UIWebview上將UITapReconizer捕獲並傳遞給UIPageviewController的最好方法是什麼?
謝謝。
我有一個uiwebview在uipageviewcontroller裏面,我希望能夠在視圖中選擇一些文本,所以我有userInteractionEnabled設置爲YES,但是當我這樣做時,我沒有選擇轉動通過點擊頁面,雖然刷卡仍然正常工作。uiwebview裏面的uipageviewcontroller塊點擊翻頁
在UIWebview上將UITapReconizer捕獲並傳遞給UIPageviewController的最好方法是什麼?
謝謝。
我已經整理了它。
我添加了一個手勢識別器控制器產生的UIWebView:
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(handleGesture:)];
tapRecognizer.numberOfTapsRequired = 1;
tapRecognizer.delegate = self;
[webView addGestureRecognizer:tapRecognizer];
隨着
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
return NO;
}
而在pageviewController添加:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
UIPageviewController
有gestureRecognizers
property
我的猜測是,如果一個公司手勢識別和你的 - 如果你使用一個 - 不能同時採取行動。 您可以通過手勢的方法處理該問題,請參閱question for handling multiple UITapGestureRecognizers,要求您的webView輕敲識別器失敗,頁面控制器的輕擊才能成功。
這樣的(未測試)
UILongPressGestureRecognizer *yourTapGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
for(UIGesture *gesture in yourPageController.gestureRecognizers){
[gesture requireGestureRecognizerToFail:yourTapGesture];
}
[pageControllerTap requireGestureRecognizerToFail:yourTapGesture];
另外,我不明白爲什麼你需要userInteractionEnabled
,是您UIWebView
採取一切空間?您可以將該手勢附加到webView的超級視圖,並使用locationInView:
方法測試webView - 命中。
試圖把網頁視圖中一個UIView作爲子視圖,並將識別器添加到UIView。 – pbibergal