I have an UIViewController
with a default swipe recognizer to open/close the right side menu of my app(I am using ECSlidingViewController
plug in). This swipe recognizer is set to the parent view of the controller.
Here is part of the code to detect the swipe to open the right side menu:
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.view addGestureRecognizer:self.slidingViewController.panGesture];}
Inside this UIViewController
i have an UIImageView
, i need to detect swipe to all directions (right,left,up,down). So far, i have set all swipes on the Storyboard
to UIImageView
, but the app only detects the swipe of one component (the one in the parent view to open the right side menu or the one in the UIImageView
), not both.
How can i make to detect swipe on both components?
The reason that happens is because your gesture recognizers on the image view are added during initWithCoder
, and your other one is added during viewDidLoad
which occurs after initWithCoder
.
If you want both to take place, you'll need to implement gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:
, otherwise iOS will just be greedy and take the latest gesture recognizer added if there is more than one for the same gesture (as you are seeing now).