Brosef
Brosef

Reputation: 3095

Multiple visible views responding to one gesture recognizer

I have a view controller that consists of three views (self.panedview, self.view, self.sineview) When a swipe up gesture is detected, the highest view (self.panedview) is moved up halfway - revealing two additional views (self.view and self.sineview). self.sineview is a UIView that constantly has an animation running that renders a moving sinewave and takes up half of self.view. I have a swipe down gesture recognizer that works when I swipe down on self.panedview, but doesn't work when I swipe down on self.sineview. If I swipe around self.sineview on self.view it seems to work. When I hide self.sineview and swipe directly down on either self.view or self.paned view, the swipe down works. do you think the animating sine wave gets in the way of the gesture recognition.

UISwipeGestureRecognizer * swipeDownRec = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleDownSwipe:)];
[self.panedView addGestureRecognizer:swipeDownRec];
[self.view addGestureRecognizer:swipeDownRec]; 
[self.sineview addGestureRecognizer:swipeDownRec];

Also I tried varying between these two lines of code but there is no difference:

    [self.view insertSubview:self.sineWave belowSubview:self.panedView];
    [self.view insertSubview:self.sineWave aboveSubview:self.view]; 

I also tried adding a separate swipe down gesture recognizer for each view, but it still doesn't work.

Upvotes: 1

Views: 83

Answers (1)

Brosef
Brosef

Reputation: 3095

The problem was the that the swipe recognizer for self.sinewave couldn't be recognized while the self.sinewave animation was enabled. The solution is simple: add UIViewAnimationOptionAllowUserInteraction as a parameter to the options handler for animateWithDuration:delay:options:animations:completion:

Upvotes: 1

Related Questions