I have three views,
View1 <-- View2 --> View3
Now View2 on leftSWipeGesture will send me to VIew3 while on right Gesture send to View1
My problem is, LeftGesture is working fine But not right gesture. I am using push Segue on both
Here is my Code
- (void) screenSwiped
{
[self performSegueWithIdentifier:@"tourSegue1" sender:self];
}
- (void) screenSwipedRight
{
[self performSegueWithIdentifier:@"tourSegue2" sender:self];
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(screenSwiped)];
swipeLeft.numberOfTouchesRequired = 1;
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeLeft];
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(screenSwipedRight)];
swipeRight.numberOfTouchesRequired = 1;
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeRight];
[super viewDidLoad];
}
The view structure you present at the start of your post is slightly misleading. From that little diagram it appears that you’re already in View 2, and going to View 1 should be a “popViewController” if you’re in a navigation controller.
So firstly – please verify this information and make sure you don’t need to “popViewController” instead of performWithSequeIdentifier (because it doesn’t work going backwards like that).