Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.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 我想在单击类的对象时删除手势识别器_Ios_Objective C - Fatal编程技术网

Ios 我想在单击类的对象时删除手势识别器

Ios 我想在单击类的对象时删除手势识别器,ios,objective-c,Ios,Objective C,我想在单击类的对象时删除手势 从我的角度来看,我将尝试下面的代码,但它不起作用。请帮帮我 - (void) registerGesture { UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTouch:)]; tapGesture.numberOfTapsRequired = 1;

我想在单击类的对象时删除手势

从我的角度来看,我将尝试下面的代码,但它不起作用。请帮帮我

- (void) registerGesture
    {
       UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTouch:)];
       tapGesture.numberOfTapsRequired = 1;
       [self.view addGestureRecognizer:tapGesture];
    }
    - (void) handleTouch:(UITapGestureRecognizer *) gesture
        {
           CGPoint touchPoint = [gesture locationInView:self.view];

           NSArray *viewsAtPoint = [self viewsAtPoint:touchPoint];

           for(TheifView * aView in viewsAtPoint)
           {
             [aView removeFromSuperview];
           }
        }
    - (NSArray *) viewsAtPoint:(CGPoint) point
    {
        NSArray *subViews = [self.view subviews];
        NSMutableArray *viewsAtPoint = [NSMutableArray new];

        for(UIView *theView in subViews)
        {
            if([theView isKindOfClass:[TheifView class]])
            {
                TheifView *theif = (TheifView *) theView;

                CGPoint convertedPoint = [theif convertPoint:point fromView:self.view];
                if([theif pointInside:convertedPoint withEvent:nil])
                {
                    [viewsAtPoint addObject:theif];
                }
            }
        }

        return viewsAtPoint;
    }

您可以使用UIGestureRecogonizerDelagte方法并删除该手势

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {

    if ([self.panGestureRecognizer isEqual:gestureRecognizer]) {

    }
    return YES;
}  

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {


    return NO;
}
定义“不工作”。