0
사용자가 1에서 5까지 왼쪽에서 오른쪽으로 라벨 카운터 업데이트를 슬라이드 할 때를 원합니다. 천천히 스 와이프하면 매우 천천히 작동하고 빠르면 올바르게 작동하지 않습니다. 이것을 구현할 다른 방법이 있습니까?touchesMoved가 충분히 빠르게 작동하지 않습니다.
나는이 코드를 가지고 :
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
gestureStartPoint = [touch locationInView:self.view];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint currentPosition = [touch locationInView:self.view];
if ((int)(currentPosition.x)%40 == 0 && counter < 5) {
counter++;
}
[label setText:[NSString stringWithFormat:@"%d", counter]];
}
제스처 인식기를 사용하십시오! UITouch는 너무 오래된 학교입니다! – MCKapur
하지만 UISwipeGestureRecognizer에서 좌표를 계산하는 방법은 무엇입니까? 스 와이프 중 라벨을 1에서 5로 업데이트하고 싶습니다. – 1337code