swipe.direction的值都是3.
下面是我以前的代码:
UISwipeGestureRecognizer *swiperight=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swichController:)];
//默认是UISwipeGestureRecognizerDirectionRight
swiperight.direction=UISwipeGestureRecognizerDirectionRight|
UISwipeGestureRecognizerDirectionLeft
;[self.collection addGestureRecognizer:swiperight];
他是错误的。
正确的用法是,要创建俩个轻拍手势,分别设定他的方向才可以。
//添加轻扫手势
UISwipeGestureRecognizer *swipe=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swichController:)];
//默认是UISwipeGestureRecognizerDirectionRight
swipe.direction=UISwipeGestureRecognizerDirectionLeft;
[self.collection addGestureRecognizer:swipe];
UISwipeGestureRecognizer *swiperight=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swichController:)];
//默认是UISwipeGestureRecognizerDirectionRight
swiperight.direction=UISwipeGestureRecognizerDirectionRight;
[self.collection addGestureRecognizer:swiperight];