- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.view];
NSLog("%f %f",currentPoint.x,currentPoint.y);
}
我想为我的iPad开发一个绘画应用程序。
当我使用这些代码并用手指在垫上画一条线时,
它是打印
[x,1),(x,3),(x,6),(x,7),(x,12),(x,15),(x,18)....
在我看来,它应该打印
(x,1),(x,2),(x,3),(x,4),(x,5),(x,6),(x,7),(x,8),(x ,9),(x,10),(x,11),(x,12),(x,13),(x,14),(x,15),(x,16),(x,17 ),(x,18)....
touchesMoved无法获得连续坐标?
最佳答案
这取决于您滑动的速度。
如果您滑动得很慢,您可能会得到(x,1),(x,2),(x,3),(x,4),(x,5),(x,6),(x,7 ),(x,8),(x,9),(x,10),但是如果快速滑动,则可以少到(x,1),(x,5),(x,10)。
如果您正在开发绘画应用程序,则必须考虑用户是否没有抬起手指,如果没有,则要画点之间的线。
祝好运!