【发布时间】:2015-06-11 15:59:49
【问题描述】:
目前使用 panGesture 的滑动并不完美。如果用户想要向上滑动,但他向右移动了一个像素,但其余像素向上(用户向上滑动,但在开始时略微向右滑动),但右侧将被激活而向上不会。我认为集成 swipeGesture 可以最大限度地减少这种错误,但它似乎不起作用。我想要它,所以当用户在开始时没有完美地向上滑动时,仍然会激活向上而不是向左或向右。它确实可以向上、向左或向右移动,但并不是 100% 完美,因为用户只需更改 y 或 x 轴,这几乎是不可能的。
-(void)pan:(UIPanGestureRecognizer *)sender
{
CGPoint distance = [sender translationInView:self.view];
UISwipeGestureRecognizer *swiping;
[myImage addGestureRecognizer: swiping];
//Not Working
if(swiping.direction == UISwipeGestureRecognizerLeft || swiping.direction == UISwipeGestureRecognizerRight) {
NSLog(@"Verticle")
} else if(swiping.direction == UISwipeGestureRecognizerUp || swiping.direction == UISwipeGestureRecognizerDown) {
NSLog(@"Horizontal");
} else if(distance.x > 0 || distance.x < 0) { // From here down working but not perfect
NSLog(@"Verticle")
} else if (distance.y < 0 || distance.y > 0) {
NSLog(@"Horizontal")
}
[sender setTranslation:CGPointZero inView:self.view];
}
【问题讨论】:
标签: ios objective-c uipangesturerecognizer uiswipegesturerecognizer