![](/img/trans.png)
[英]Error in Swipe Gesture Recognizer during navigating from one page to other
[英]using swipe gesture recognizer swipe from one viewcontroller to another
向右滑动
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(slideToRightWithGestureRecognizer:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeRight];
向左滑动
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(slideToLeftWithGestureRecognizer:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeLeft];
在“ slideToRightWithGestureRecognizer
”方法上,我想编写代码,以打开在故事板上具有视图控制器的abcViewController,并与“ slideToLeftWithGestureRecognizer
”相同,以打开xyzViewController,在故事板上也具有视图控制器。 在程序中不使用Navigation View Controller
应该很容易完成:
当ViewController连接到情节提要上时,您可以轻松地做到这一点:
- (void)slideToLeftWithGestureRecognizer:(id)sender {
[self performSegueWithIdentifier:@"myConnectionIdentifierHere"]
}
如果不:
- (void)slideToLeftWithGestureRecognizer:(id)sender {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"myStoryboardName" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"myViewControllerIdentifierHere"];
[self presentViewController:vc animated:YES completion:nil];
}
您是否考虑过使用UIPageViewController
? 还是必须一定要滑动而不是平移手势(UIPageViewController使用交互的平移手势在视图控制器之间提供导航)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.