【发布时间】:2016-09-08 09:54:44
【问题描述】:
我有一个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]];
}
}
【问题讨论】:
标签: ios objective-c qlpreviewcontroller uilongpressgesturerecogni