How can I detect which way the user swiped my page view controller? This should be simple but I cannot seem to find a reliable way to do this! Can anyone help me with a simple answer to tell which way the user has swiped a page!
如何检测用户刷页面控制器的方式?这应该很简单,但我似乎无法找到一个可靠的方法来做到这一点!任何人都可以帮我一个简单的答案来告诉用户刷了一个页面的方式!
Thanks.
2 个解决方案
#1
There could be functions like first touch and last touch. So you can understand the direction by simple aritmetical operations. Then swipe won't be too different initial and ending point are key elements for understanding the direction as well.
可能有第一次触摸和最后一次触摸等功能。所以你可以通过简单的aritmetical操作来理解方向。然后滑动不会太大不同初始和终点也是理解方向的关键因素。
I assume you have already checked it but may missed little details.
我假设你已经检查了它,但可能错过了一些细节。
Here - Apple Developers Site
这里 - Apple开发者网站
#2
Left swipe used this:
左滑动使用了这个:
UISwipeGestureRecognizer* leftSwipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleLeftSwipe:)];
leftSwipeRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[self.tableView addGestureRecognizer:leftSwipeRecognizer];
Right swipe used this:
右键滑动使用了这个:
UISwipeGestureRecognizer* rightSwipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleRightSwipe:)];
rightSwipeRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[self.tableView addGestureRecognizer:rightSwipeRecognizer];
#1
There could be functions like first touch and last touch. So you can understand the direction by simple aritmetical operations. Then swipe won't be too different initial and ending point are key elements for understanding the direction as well.
可能有第一次触摸和最后一次触摸等功能。所以你可以通过简单的aritmetical操作来理解方向。然后滑动不会太大不同初始和终点也是理解方向的关键因素。
I assume you have already checked it but may missed little details.
我假设你已经检查了它,但可能错过了一些细节。
Here - Apple Developers Site
这里 - Apple开发者网站
#2
Left swipe used this:
左滑动使用了这个:
UISwipeGestureRecognizer* leftSwipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleLeftSwipe:)];
leftSwipeRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[self.tableView addGestureRecognizer:leftSwipeRecognizer];
Right swipe used this:
右键滑动使用了这个:
UISwipeGestureRecognizer* rightSwipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleRightSwipe:)];
rightSwipeRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[self.tableView addGestureRecognizer:rightSwipeRecognizer];