我有一个简单的应用程序,可以打印所有触摸事件的坐标。在模拟器中效果很好。
在我的设备 (iPhone) 上,它最多可以使用两个手指。当我用三个手指快速点击时,事件touchesCancelled
被触发。
有人可以向我解释一下吗?这是位于我的 UIView 中的打印代码(以防出现问题)。
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *touch in touches) {
CGPoint location = [touch locationInView:touch.view];
NSLog(@"Began %f %f", location.x, location.y);
}
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *touch in touches) {
CGPoint location = [touch locationInView:touch.view];
NSLog(@"Moved %f %f", location.x, location.y);
}
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *touch in touches) {
CGPoint location = [touch locationInView:touch.view];
NSLog(@"Ended %f %f", location.x, location.y);
}
}
-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"Phase: Touches cancelled");
for (UITouch *touch in touches) {
CGPoint location = [touch locationInView:touch.view];
NSLog(@"Cancelled %f %f", location.x, location.y);
}
}
序列的一个例子是这个:
Began 38.000000 263.000000
Began 173.500000 238.500000
Moved 41.500000 263.000000
Phase: Touches cancelled <<<< third touch
Cancelled 41.500000 263.000000
Cancelled 173.500000 238.500000
谢谢你。