gpt4 book ai didi

objective-c - iOS - touchesMoved 在子类 UIScrollView 中只调用一次

转载 作者:行者123 更新时间:2023-11-28 18:40:22 25 4
gpt4 key购买 nike

我正在尝试将可移动的 UIImageView 放入子类 UIScrollView 中,以便我可以将它们拖到我的 UIScrollView 周围。我将 UISCrollView 子类化并且放置行为有效,但是当我尝试拖动图像时,touchesMoved 仅被评估一次。我的 UIScrollView 子类中的 touchesMoved 方法如下所示:

-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
if (!self.dragging) {
[self.nextResponder touchesMoved: touches withEvent:event];
}else{
[super touchesEnded:touches withEvent:event];
}
}

它应该在移动触摸期间连续调用。谁能想到我的 View Controller 中的 touchesMoved 方法只被调用一次的原因?

最佳答案

IOS 5: UIScrollView not pass touches to nextResponder

代替:

[self.nextResponder touchesMoved:touches withEvent:event];使用:

[[self.nextResponder nextResponder] touchesMoved:touches withEvent:event];

关于objective-c - iOS - touchesMoved 在子类 UIScrollView 中只调用一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11726900/

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