码迷,mamicode.com
首页 > 其他好文 > 详细

判断手势事件向左还是向右

时间:2014-11-12 00:34:54      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   color   ar   sp   div   on   log   

首先在view上添加手势 UIPanGestureRecognizer

1 UIPanGestureRecognizer *panGes = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(goAnimation:)];
2 
3  [self.view addGestureRecognizer:panGes];

 


在滑动方法当中根据 translationInView 这个方法返回的点的正负来判断向左还是向右 大于0说明向左,小于0说明向右 

UIPanGestureRecognizer *pan = (UIPanGestureRecognizer *)sender;
CGPoint point = [pan translationInView:self.view];
if (point.x>0) {
    //向左滑动
}else{
    //向右滑动
}

 

判断手势事件向左还是向右

标签:style   blog   io   color   ar   sp   div   on   log   

原文地址:http://www.cnblogs.com/mgbert/p/4090895.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!