【发布时间】:2012-02-16 23:54:54
【问题描述】:
我找不到任何东西来解释丢失的 UITouch 事件。如果您将整只手砸在屏幕上的次数足够多,则 touchesBegan 的次数将不同于 touchesEnded 的次数!我认为真正了解这些孤立触摸的唯一方法是自己参考它们并跟踪它们多久没有移动。
示例代码:
int touchesStarted = 0;
int touchesFinished = 0;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
touchesStarted += touches.count;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
touchesFinished += touches.count;
NSLog(@"%d / %d", touchesStarted, touchesFinished);
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
[self touchesEnded:touches withEvent:event];
}
【问题讨论】:
-
更新了我的回复以包含一个新理论。
-
如果您修正接受评级,我相信您会收到更多答案。目前为 0%。
标签: iphone ios multi-touch uievent