OGeek|极客世界-中国程序员成长平台

标题: iphone - touchesMoved 在没有 touchesBegan 的情况下调用 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 12:11
标题: iphone - touchesMoved 在没有 touchesBegan 的情况下调用

我在一个容器中有许多自定义 UIView,我会在用户移动它们后对其进行动画处理。为了跟踪他们的移动,我使用 touchesBegan: 获取当前位置,并使用 touchesMoved: 更新位置。

有时,特别是如果我最近移动了一个 View (并且它可能仍在动画回其原始位置),如果我开始拖动另一个 View ,则不会调用 touchesBegan: 选择器,但 touchesMoved:touchesEnded: 会。如何在不首先在 View 上调用 touchesBegan: 的情况下调用 touchesMoved:touchesEnded:



Best Answer-推荐答案


我发现我的应用存在类似问题。当我为另一个 View 设置动画时,如果我快速触摸第一个 View 并开始滑动,则不会发生 touchesBegan 事件,但一旦第一个 View 消失,我就会开始获取 touchesMoved。

根据这个答案,app starts ignores user interaction events when i call animateWithDuration:delayptions:animations:completion: ,用户交互事件在制作动画时会被忽略,我认为这与我们所看到的一致。尝试使用 UIViewAnimationOptionAllowUserInteraction 选项或 userInteractionEnabled 属性;这应该允许事件按您的要求通过。

关于iphone - touchesMoved 在没有 touchesBegan 的情况下调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9676545/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4