缩短UIScrollView中的触摸延迟?

我正在寻找缩短UIScrollView触摸延迟,但我不想使用setDelaysContentTouches:NO; 我仍然希望稍微延迟一些,但是我的用户抱怨这个时间太长了。

有没有办法做到这一点?

医生说

如果用户在计时器过去之前拖动手指足够远,则滚动视图取消子视图中的任何跟踪,并执行滚动本身。 子类可以覆盖touchesShouldBegin:withEvent:inContentView:,pagingEnabled和touchesShouldCancelInContentView:方法(由滚动视图调用)来影响滚动视图如何处理滚动手势。

所以我觉得有没有简单的方法来做到这一点。 您可能不得不在这些方法中重新实现整个计时器系统。

我刚刚遇到这个问题,这是我的解决scheme:

子类UIScrolView

添加覆盖这些方法:

- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view { self.lastTimestamp = [NSDate date]; return [super touchesShouldBegin:touches withEvent:event inContentView:view]; } - (BOOL)touchesShouldCancelInContentView:(UIView *)view { NSDate *now = [NSDate date]; if (-[self.lastTimestamp timeIntervalSinceDate:now] < _delay) return YES; return NO; }