gpt4 book ai didi

iphone - 如何取消一系列 UITouch 事件?

转载 作者:IT王子 更新时间:2023-10-29 08:06:26 25 4
gpt4 key购买 nike

我有一个响应触摸事件的 UIImage View 。我想取消触摸序列,即,如果触摸超出特定范围,则进一步调用 touchesMoved:。我该怎么做?

我知道在 touchesMoved: 中我可以检查触摸对象的坐标并忽略它,但我不知道如何完全取消序列。我没有看到 Apple Developer UIResponder Reference 中记录的任何方法我可以调用它来取消触摸序列。

最佳答案

这个解决方案可能有点笨拙,但你可以实现并手动调用

- (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;

我将此解决方案大致基于我对 Apple 的 iPhone sample code 上的 MoveMe 示例应用程序所做的一些调整。我将 touchesMoved 方法修改为如下所示的站点:

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
if ([touch view] == placardView)
CGPoint location = [touch locationInView:self];
placardView.center = location;
// I added the following line:
[self touchesCancelled:touches withEvent:event];
return;
}

关于iphone - 如何取消一系列 UITouch 事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/533574/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com