我有一个UIView
作为主视图并QLPreviewController
在预览文档时添加一个作为子视图。我想限制长按手势,以便没有人可以从文档中复制内容。我尝试了以下代码:
代码片段:
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:nil];
longPress.allowableMovement=100;
longPress.minimumPressDuration=0.3;
longPress.delegate=self;
longPress.delaysTouchesBegan=YES;
longPress.delaysTouchesEnded=YES;
longPress.cancelsTouchesInView=YES;
[previewController.view addGestureRecognizer:longPress];
[self.view addSubview:previewController.view];
但没有成功。谁能告诉我我哪里出错了,可以做些什么来禁用长按手势?
我也试过这个:
NSArray *arr = previewController.view.gestureRecognizers;
for (int i = 0; i < arr.count; i++) {
if ([[arr objectAtIndex:i] isKindOfClass:[UILongPressGestureRecognizer class]]) {
[previewController.view removeGestureRecognizer:[arr objectAtIndex:i]];
}
}