Ios 目标C:当手指仍在屏幕上时识别刷卡手势
我的屏幕上有图像视图,当用户不停地从左向右和从右向左滑动此图像时,我想要检测。当他这么做的时候,他的手指还在屏幕上。我要添加到我的Ios 目标C:当手指仍在屏幕上时识别刷卡手势,ios,objective-c,swipe,Ios,Objective C,Swipe,我的屏幕上有图像视图,当用户不停地从左向右和从右向左滑动此图像时,我想要检测。当他这么做的时候,他的手指还在屏幕上。我要添加到我的swipcount变量的每次刷卡。 我试过这个: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; self.startPosition = [touch locationInView:self
swipcount
变量的每次刷卡。
我试过这个:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
self.startPosition = [touch locationInView:self.imageView];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint endPosition = [touch locationInView:self.imageView];
if (self.startPosition.x != endPosition.x || self.startPosition.y != endPosition.y) {
self.swipeCount++;
self.labelSwipeCount.text = [NSString stringWithFormat:@"%d", self.swipeCount];
}
}
但是,如果用户不超出图像范围,touchesEnded就不起作用。我怎样才能实现我的想法