[英]Swipe between ViewController with Storyboard
I'm currently trying to connect different ViewControllers by swipe left but,The my code not work for me. 我目前正在尝试通过向左滑动来连接不同的ViewController,但是,我的代码对我不起作用。 I added Swipe gesture recognizer to the ViewController in stroyboard file This my code
我在滑动面板文件的ViewController中添加了Swipe手势识别器这是我的代码
UISwipeGestureRecognizer *swipeLeftGesture=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGesture:)];
[self.view addGestureRecognizer:swipeLeftGesture];
swipeLeftGesture.direction=UISwipeGestureRecognizerDirectionLeft;
}
-(void)handleSwipeGesture:(UIGestureRecognizer *) sender
{
NSUInteger touches = sender.numberOfTouches;
if (touches == 2)
{
if (sender.state == UIGestureRecognizerStateEnded)
{
//Add view controller here
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPhone6" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
[self presentViewController:vc animated:YES completion:nil];
}
}
}
Although you can do this manually, many people have built tools to help you do this. 尽管您可以手动执行此操作,但是许多人已经构建了可帮助您执行此操作的工具。 I recommend RKSwipeBetweenViewControllers .
我推荐RKSwipeBetweenViewControllers 。 Easy to set up, easy to use.
易于设置,易于使用。
No more thinking about UISwipeBetweenViewControllers
! 不用再考虑
UISwipeBetweenViewControllers
!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.