Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove gesture recogniser

SO, I am adding a gesture recogniser to an overlay view. When tapped on screen i want this overlay to go away. Having said that adding a gesture recognizer overrides the "touch up inside" and other button click events. I need this back therefore i need to removegesturerecognizer. I can use this method however i have a problem. My code below -

- (void)helpClicked {     CGRect visibleBounds = [self convertRect:[self bounds] toView:viewContainer];     CGFloat minimumVisibleX = CGRectGetMinX(visibleBounds);     UIImageView * helpOverlay = [[UIImageView alloc]initWithFrame:CGRectMake(minimumVisibleX, 0, 1024, 768)];     UIImage * helpImage = [UIImage imageNamed:@"HelpOverLay.png"];     [helpOverlay setImage:helpImage];     helpOverlay.tag = 50;     self.scrollEnabled = NO;     [self addSubview:helpOverlay];      UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]                                 initWithTarget:self                                action:@selector(dismissView)];  [self addGestureRecognizer:tap];     

}

Here i am taking the overlay off the other view.

- (void) dismissView {     UIView *overlay = [self viewWithTag:50];     [overlay removeFromSuperview];     self.scrollEnabled = YES; } 

My question is how do i remove the gesture recognizer in the second method? I cant pass the variable tap into this method nor can i remove it in the previous method either. Any pointers? Ive been stuck with quite a lot of passing variable problems when it comes to events.

like image 630
CodeGeek123 Avatar asked Jun 08 '12 11:06

CodeGeek123


1 Answers

This loop will remove all gesture recognizers a view has

for (UIGestureRecognizer *recognizer in self.view.gestureRecognizers) {     [self.view removeGestureRecognizer:recognizer]; } 
like image 104
Omar Abdelhafith Avatar answered Oct 08 '22 04:10

Omar Abdelhafith