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