【问题标题】:iOS touch events not being received in the correct order (touch ended not called at the right time)未按正确顺序接收 iOS 触摸事件(未在正确时间调用触摸结束)
【发布时间】:2011-12-02 20:08:27
【问题描述】:

所以我试图以这个确切的顺序捕捉以下行为

touch 1 STARTED
touch 1 moved
touch 1 moved

touch 2 STARTED
touch 2 moved
touch 2 ENDED

touch 1 moved
touch 1 moved
touch 1 ENDED

但相反,他们以错误的顺序返回:

2011-12-02 14:55:37.187 coreplotround2[7396:707] touch 1 STARTED
2011-12-02 14:55:41.182 coreplotround2[7396:707] touch 1 moved
2011-12-02 14:55:41.582 coreplotround2[7396:707] touch 1 moved

2011-12-02 14:55:41.743 coreplotround2[7396:707] touch 2 STARTED
2011-12-02 14:55:41.902 coreplotround2[7396:707] touch 1 moved
2011-12-02 14:55:41.904 coreplotround2[7396:707] touch 2 moved <---- at this point my 2nd finger is released!!

2011-12-02 14:55:45.533 coreplotround2[7396:707] touch 1 moved
2011-12-02 14:55:45.533 coreplotround2[7396:707] touch 1 moved
2011-12-02 14:55:45.533 coreplotround2[7396:707] touch 1 moved
2011-12-02 14:55:45.533 coreplotround2[7396:707] touch 1 moved
2011-12-02 14:55:45.533 coreplotround2[7396:707] touch 1 moved
2011-12-02 14:55:45.549 coreplotround2[7396:707] touch 1 ENDED
2011-12-02 14:55:45.566 coreplotround2[7396:707] touch 2 ENDED

问题是 touch 2 ENDED 与 touch 1 ENDED 同时出现,即使 touch 2 结束得早得多。

我正在使用方法 touchesBegan、touchesMoved、touchesEnded。

有人知道为什么吗?

【问题讨论】:

  • 用给定的信息很难说清楚。您可以发布您的触摸代码的 sn-p 吗?此外,有时如果您重叠触摸,iPhone 会感到困惑并将它们合二为一。

标签: ios uitouch


【解决方案1】:

我发现了原因。我从 Core Plot 图形库中继承了一个对象。这个对象是 UIView 的一个子类,所以我希望它能够接收到触摸。因此,我重新声明了触摸侦听器并尝试尝试查看它们的行为方式。

我相信在这个特定的 Core Plot 对象中发生了一些奇怪的事情,它与触摸顺序发生了冲突。我无法告诉你那是什么。

我通过创建一个带有空视图的新项目并测试多点触控来发现这一点。

我决定在其上创建一个 UIView 来拦截多点触控,然后在 Core Plot 中调用适当的委托,而不是子类化 Core Plot。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-26
    • 2014-08-14
    • 1970-01-01
    相关资源
    最近更新 更多