使用滑动手势切换视图控制器 [英] switching view controllers using swipe gestures
本文介绍了使用滑动手势切换视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,这就是我遇到的问题:
Okay so here is the problem I'm running into:
我试图从一个 viewController切换
我命名 MenuViewController
,其中包含我的菜单(显然)。我有一个单独的 viewController
名为 ViewController
,其中包含我的 mapView
。我希望能够将我的 MenuViewController
中的双手向左滑动
转到我的 mapView
。
I am attempting to switch from one viewController
that I named MenuViewController
which contains my menu (obviously). I have a separate viewController
named ViewController
that contains my mapView
. I would like to be able to double finger swipe left
from my MenuViewController
over to my mapView
.
我不确定从哪里开始。
I'm not exactly sure where to start.
另外,我使用的是xib文件,而不是故事板。运行iOS 6.
Also, I am using xib files, and not the storyboard. Running iOS 6.
推荐答案
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
}
}
}
这篇关于使用滑动手势切换视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文