好的,我弄清楚了UITapGestureRecognizer
. 您需要将委托设置为自我,然后覆盖
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
函数并返回是。所以在我的 QLPreviewController 子类中,我实现了 UIGestureRecognizerDelegate,并在 viewWillAppear 中:
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(documentTapped:)];
tapGesture.cancelsTouchesInView = NO;
tapGesture.delegate = self;
[self.view addGestureRecognizer:[tapGesture autorelease]];
然后简单地说:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
这样,QLPreviewController 仍将接收所有其他非点击触摸事件,以便用户仍然可以与文档交互