使用三个手指时触发 TouchsCancelled
我有一个简单的应用程序,可以打印所有触摸事件的坐标。 在模拟器中效果很好。
在我的设备 (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
谢谢。
I have a simple app that prints the coordinates of all the touches event.
In the simulator it works great.
On my device (iPhone) it works great with up to two fingers. When I tap with three fingers in a fast sequence the event touchesCancelled
is triggered.
Could someone please explain this to me?
This is the code for printing (in case the problem lays there) that sits in my 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);
}
}
An example of sequence is this one:
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
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论