Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIPinchGestureRecognitor禁用夹出_Ios_Objective C_Uipinchgesturerecognizer - Fatal编程技术网

Ios UIPinchGestureRecognitor禁用夹出

Ios UIPinchGestureRecognitor禁用夹出,ios,objective-c,uipinchgesturerecognizer,Ios,Objective C,Uipinchgesturerecognizer,我在滚动视图中添加了一个捏手势识别器,用它来关闭模式视图控制器。我是这样做的: UIPinchGestureRecognizer *closePinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(closeGallery)]; [galleryScrollView addGestureRecognizer:closePinch]; 虽然它被添加到scrollView中,但实际上我并没有使用它

我在滚动视图中添加了一个捏手势识别器,用它来关闭模式视图控制器。我是这样做的:

UIPinchGestureRecognizer *closePinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(closeGallery)];
[galleryScrollView addGestureRecognizer:closePinch];
虽然它被添加到scrollView中,但实际上我并没有使用它来缩放视图,而只是关闭视图。因此,我不需要尖灭手势,因为它表示放大

是否有一种方法可以轻松禁用手势识别器的收缩部分并保持收缩不动

根据Crazyrems的回答,以下委托方法正是我所需要的:

- (BOOL)gestureRecognizerShouldBegin:(UIPinchGestureRecognizer *)gestureRecognizer
{
    // Negative velocity indicates pinch out
    if (gestureRecognizer.velocity < 0) {
        return YES; // <- Register touch event
    } else {
        return NO; // <- Do not register touch event
    }
}
-(BOOL)手势识别器应开始:(uipinchgesturecognitioner*)手势识别器
{
//负速度表示尖灭
if(GestureRecognitor.velocity<0){

返回YES;//您应该在您的
UIgestureRecognitizerDelegate中实现
-gestureRecognitizer应该开始:


在传入的识别器参数中有一个
velocity
属性,因此您可以检查它是否为插入或退出,然后返回
YES
NO

非常有效,谢谢。我还根据您的回答在我的问题中添加了代码!