Reputation: 243
Swipe-Right
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(slideToRightWithGestureRecognizer:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeRight];
Swipe-Left
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(slideToLeftWithGestureRecognizer:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeLeft];
On 'slideToRightWithGestureRecognizer
' method i want to write code which opens abcViewController which has a viewcontroller on storyboard and same with 'slideToLeftWithGestureRecognizer
' to open xyzViewController which also has view controller on storyboard. Without using Navigation View Controller in the program
Upvotes: 0
Views: 987
Reputation: 10466
Have you considered using UIPageViewController
? Or does it necessarily have to be a swipe and not a pan gesture (UIPageViewController provides navigation between view controllers using a pan gesture interactively).
Upvotes: 1
Reputation: 3275
Should be very easy to accomplish:
When the ViewControllers are connected on your storyboard you could easily do it like this:
- (void)slideToLeftWithGestureRecognizer:(id)sender {
[self performSegueWithIdentifier:@"myConnectionIdentifierHere"]
}
If not:
- (void)slideToLeftWithGestureRecognizer:(id)sender {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"myStoryboardName" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"myViewControllerIdentifierHere"];
[self presentViewController:vc animated:YES completion:nil];
}
Upvotes: 1