0
votes

Im trying to swipe between view controllers using the Swipe Gesture Recognizer Object in the StoryBoard, but doesn't work.

  • The App consists in one Tab Bar Controller and 4 view controllers, each view controller have a view, table view, table view cell and image view.
  • Firstly I've dragged the object to each view controller, after this I've used the ctrl + drag the object to the destination view controller to create the "Push segue to View Controller" selecting the Action segue = push, I gave it an identifier, I've unchecked the cancels touch in view and finally I've checked the user interaction enabled.

How can I do to get that the App swipes?

1

1 Answers

1
votes

You can do this programmatically by adding a gesture recognizer to the view controller. In your - (void)viewDidLoad method of a view controller you can add the following:

UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipedRight)];
swipeRight.numberOfTouchesRequired = 1;
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeRight];

Then create - (void)swipedRight in your view controller. If you want to call a segue you've created in the story board then you can just put [self performSegueWithIdentifier:@"segueID" sender:self]; in your swipedRight function.