So I am trying to add a swipe gesture to one of the subviews on a screen in my application. I declare the gesture recognizers as follows:
UISwipeGestureRecognizer *swiperR = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(switchStackingMode:)];
[swiperR setDirection:UISwipeGestureRecognizerDirectionRight];
[chart addGestureRecognizer:swiperR];
UISwipeGestureRecognizer *swiperL = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(switchStackingMode:)];
[swiperL setDirection:UISwipeGestureRecognizerDirectionLeft];
[chart addGestureRecognizer:swiperL];
-(void)switchStackingMode:(UISwipeGestureRecognizer *)sender {
NSLog(@"inside switchstack from gesture");
//other stuff
}
When I attempt to interact with the subview on application launch, only the swipe gesture swiperL works. I get no response on a right swipe. I initially tried doing only one gesture recognizer with direction (UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight) but that didn't work, and based off other stack overflow answers I reverted to two separate recognizers. Still no luck, and this has me puzzled. I feel like I'm missing something..
I answered this here Setting direction for UISwipeGestureRecognizer. I believe the bug is that you can't have your "action" names be the same, i.e. don't have both selectors named "switchStackingMode". Use switchStackingModeRight and switchStackingModeLeft.