2
votes

So I have a homepage view that people see when they first boot up the app, it has several different options. Yesterday I added a tutorial overlay, so the first time they open the app I have a view that is 0.5 alpha black and is fullscreen over the other view, this view has white text and arrows pointing to functions on the page. I attached a tap gesture recognizer to this view and its action is to call the next tutorial screen ( 3 in total). Afterwords they all are hidden and the app acts as normal. This all works, except even though my view is full screen, with User Interaction Enabled checked and a gesture tap recognizer, the gestures / touches on the sub view still work. So if I just tap some white space on the app the tutorial and tap gesture work as expected, cycle me through the pages etc and works. However if I accidentally press a sub view button or do a gesture from the subview it will do the action (take you to a new page or w/e)

So basically as far as I can tell my view despite being on top of the other and having a tap gesture recognizer attached to the view the sub views are still getting pressed, any ideas?

2
since you are added tap gesture to your main view all its subViews will get this gesture.Vaisakh
Is there a way to disable this or override it ?CMOS

2 Answers

1
votes

Check the tap event view before doing any operation..

- (IBAction)yourTapEvent:(UITapGestureRecognizer *)gestureRecognizer
    {
        UIView *piece = [gestureRecognizer view];

        if(piece  == (view on which you have added gesture))
        {
            //Do your necessary operation
        }

    }
0
votes

try this it would help you to disable gesture on its subviews

 - (void)tapAction:(UITapGestureRecognizer *) gestureRecognizer{
      UIView *v = [gestureRecognizer view];// Guesture added view
        NSArray *temp = [self.view subviews];
        for (int i = 0; i<temp.count; i++) {
            if([temp objectAtIndex:i]== v){
                // Do your swipe tap action here
            }
        }
    }