iOS手势之UISwipeGestureRecognizer的正确用法
2016-03-06 17:29
453 查看
今天,我在用到UISwipeGestureRecognizer滑动控制器的时候,发现无论往那个方向滑动,
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];
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];
相关文章推荐
- POJ 2785 4 Values whose Sum is 0
- 关于UITableView中cell的重用问题
- UITextField实现PlaceHolder
- Unexpected Exception caught setting 'x' on class xx:Error setting expression 'xx' with value ['x',]
- UIActivity头文件学习
- swif之UITableViewCell和UITableView常见属性复习
- POJ 3061 Subsequence【尺取法】
- 错误svn: The repository at 'svn://xxxxx' has uuid 'XXXX', but the WC has 'XXXX'“
- Qt中ui文件的使用
- SharePoint 2010 - Hardware and Software Requirements
- Binary Expression and Value Expression
- UIActivityIndicatorView的使用
- 如何设置约束让三个按钮平分UIView容器的宽度的方法
- UIActivityViewController头文件学习
- Android UI优化
- 1051. Pop Sequence (25) 判断出栈序列是否合理
- [LeetCode]62. Unique Paths
- LA 4287(p322)----Proving Equivalences
- 一起看代码来玩玩QT之18 database (last QSqlQueryModel 对数据库进行操作(只查不能改)QTableModel 可改,但是QSqlQueryModel也可以添加代理等功)
- Maximum Subsequence Sum