添加UIGestureRecognizer从左到右从右到左滑动我的意见

我有一个UIStoryboard与不同的UIViewControllers ,我想添加另一个UIViewController (如仪表板),当用户从左侧滑动iPad的仪表板将出现,然后当他向后滑动当前视图将被恢复。

这可能吗? 如果是的话提示如何做或UIGestureRecognizer任何好的教程?

谢谢。

//向左滑动

 UISwipeGestureRecognizer * swipeleft=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeleft:)]; swipeleft.direction=UISwipeGestureRecognizerDirectionLeft; [self.view addGestureRecognizer:swipeleft]; 

// SwipeRight

 UISwipeGestureRecognizer * swiperight=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swiperight:)]; swiperight.direction=UISwipeGestureRecognizerDirectionRight; [self.view addGestureRecognizer:swiperight]; 

//实现手势方法

 -(void)swipeleft:(UISwipeGestureRecognizer*)gestureRecognizer { //Do what you want here } -(void)swiperight:(UISwipeGestureRecognizer*)gestureRecognizer { //Do what you want here } 

试试这个。