在我的應用程序我使用touchesMoved方法來檢測左/右滑動。 當用戶連續向左和向右滑動時,圖像動畫會自動更新。 我能夠檢測到滑動動作,但有時當我開始連續向左和向右滑動時,屏幕不會檢測到touchmoved事件。touchesMoved檢測不能正常工作
在滑動區域我已經爲動畫放置了一個隱藏按鈕和幾個ImageView。 我想知道它爲什麼發生。請幫助我。
謝謝。
代碼:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesMoved:touches withEvent:event];
UITouch *touch = [touches anyObject];
CGPoint newLocation = [touch locationInView:self.view];
CGPoint oldLocation = [touch previousLocationInView:self.view];
if(newLocation.x-oldLocation.x>0){
swipe_direction = 1;
//NSLog(@"left");
}
else{
swipe_direction = 2;
//NSLog(@"right");
}
if(swipe_direction == 1){
//animate images
}
else if(swipe_direction == 2){
//animate images
}
}