我想跟踪从touchesBegan
一直touchesMoved
到touchesEnded
. 我正在获取单次触摸事件的坐标,但我想知道哪个触摸事件对应于哪个触摸事件序列。
例如,如果我在屏幕上移动食指,然后用食指触摸屏幕,然后移开食指 - 我想用红色显示食指的坐标,用红色显示食指的坐标蓝色。
这可能吗?如果是,我如何确定哪些事件应该是“红色”,哪些事件应该是“蓝色”?
这是我的代码:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self handleTouches:[event allTouches]];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self handleTouches:[event allTouches]];
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[self handleTouches:[event allTouches]];
}
-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
[self handleTouches:[event allTouches]];
}
- (BOOL)handleTouches: (NSSet*)touches {
for (UITouch* touch in touches) {
// ...
}
}