Ios 使用滑动手势识别器从一个viewcontroller滑动到另一个viewcontroller
向右滑动Ios 使用滑动手势识别器从一个viewcontroller滑动到另一个viewcontroller,ios,objective-c,uiswipegesturerecognizer,Ios,Objective C,Uiswipegesturerecognizer,向右滑动 UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(slideToRightWithGestureRecognizer:)]; swipeRight.direction = UISwipeGestureRecognizerDirectionRight; [self.view addGestureRecognizer:sw
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];
在“
SlideToRightWithGestureRecognitizer
”方法中,我想编写代码,打开故事板上有viewcontroller的abcViewController,并与“SlideToLeftWithGestureRecognitizer
”相同,以打开故事板上也有view controller的xyzViewController。不使用程序中的导航视图控制器应该很容易实现:
在故事板上连接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以交互方式使用平移手势在视图控制器之间提供导航)。您的故事板上是否连接了这些视图控制器,或者它们是否具有ID?给我们看看你的setup@Daniel我给了他们故事板,实际上它目前是通过PageViewController实现的,它使用按钮,当我们按住并拖动它们时,它会移动,所以在每个ViewController(三视图控制器)的左侧和右侧都有按钮。我的任务是删除按钮,当用户向左滑动时,它将转到leftviewController,当用户向右滑动时,它将转到rightViewController